Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed public directory when configured in composer.json #29533

Merged

Conversation

alexander-schranz
Copy link
Contributor

@alexander-schranz alexander-schranz commented Dec 8, 2018

Q A
Branch? 3.4
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #...
License MIT

As documented you should be able to change the public-dir by composer.json so the server:run and assets:install should also use that configuration when available:

https://symfony.com/doc/3.4/configuration/override_dir_structure.html#override-the-web-directory
https://symfony.com/doc/current/configuration/override_dir_structure.html#override-the-public-directory

#SymfonyConHackDay2018

@alexander-schranz alexander-schranz force-pushed the bugfix/web-server-public-dir branch 2 times, most recently from f3effd2 to 96c6e41 Compare December 8, 2018 16:08
@alexander-schranz alexander-schranz changed the title Fixed public directory of web server when configured in composer.json Fixed public directory when configured in composer.json Dec 8, 2018
@nicolas-grekas nicolas-grekas added this to the 3.4 milestone Dec 8, 2018
@nicholasruunu
Copy link
Contributor

nicholasruunu commented Dec 8, 2018

Instead of duplicating the public directory code, I feel like this could be put into a PublicDirectory(ContainerInterface) class.

-- edit --
Or even just PublicDirectory(string projectRoot)

@alexander-schranz
Copy link
Contributor Author

@nicholasruunu but in which namespace without adding additional requirements to the compoments?

@chalasr
Copy link
Member

chalasr commented Dec 8, 2018

I don't think it's worth adding a new class.

@nicholasruunu
Copy link
Contributor

@alexander-schranz @chalasr, True, nevermind.

@ro0NL
Copy link
Contributor

ro0NL commented Dec 8, 2018

it could be %kernel.public_dir%, but that be a new feature also

nicolas-grekas
nicolas-grekas previously approved these changes Dec 12, 2018
Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(with one minor comment)

@alexander-schranz alexander-schranz force-pushed the bugfix/web-server-public-dir branch 2 times, most recently from 3654c68 to a4ad090 Compare December 12, 2018 17:55
@alexander-schranz
Copy link
Contributor Author

@nicolas-grekas tests green now :)


$composerConfig = json_decode(file_get_contents($composerFilePath), true);

if (isset($composerConfig['extra']['public-dir'])) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we also account for symfony-web-dir which is still used for application based on the Symfony Standard Edition?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we discussed about it in #29533 (comment)
wdyt?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed the discussion, but SensioDistributionBundle only handles the case when assets are installed using Composer scripts. IMO being able to run the command without having to specify the argument would be nice. On the other hand, anyone using 3.4 probably is already used to doing this. So maybe it's not worth it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

anyone using 3.4 probably is already used to doing this. So maybe it's not worth it.

same opinion here :)

$composerConfig = json_decode(file_get_contents($composerFilePath), true);

if (isset($composerConfig['extra']['public-dir'])) {
$publicDir = $composerConfig['extra']['public-dir'];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we do a ltrim($publicDir, '/') here to be completely sure that we won't have double slashes later?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is ok for me what do you think @nicolas-grekas?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why should we care?

@nicolas-grekas
Copy link
Member

Thank you @alexander-schranz.

@nicolas-grekas nicolas-grekas merged commit c45062b into symfony:3.4 Dec 17, 2018
nicolas-grekas added a commit that referenced this pull request Dec 17, 2018
…lexander-schranz)

This PR was merged into the 3.4 branch.

Discussion
----------

Fixed public directory when configured in composer.json

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? |  no
| Tests pass?   | yes
| Fixed tickets | #...   <!-- #-prefixed issue number(s), if any -->
| License       | MIT

As documented you should be able to change the public-dir by composer.json so the server:run and assets:install should also use that configuration when available:

https://symfony.com/doc/3.4/configuration/override_dir_structure.html#override-the-web-directory
https://symfony.com/doc/current/configuration/override_dir_structure.html#override-the-public-directory

#SymfonyConHackDay2018

Commits
-------

c45062b fixed public directory of web server and assets install when configured in composer.json
@alexander-schranz alexander-schranz deleted the bugfix/web-server-public-dir branch December 17, 2018 10:13
This was referenced Jan 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants