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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,8 +27,31 @@ public function load(array $configs, ContainerBuilder $container) | |
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); | ||
$loader->load('webserver.xml'); | ||
|
||
$publicDirectory = $this->getPublicDirectory($container); | ||
$container->getDefinition('web_server.command.server_run')->replaceArgument(0, $publicDirectory); | ||
$container->getDefinition('web_server.command.server_start')->replaceArgument(0, $publicDirectory); | ||
|
||
if (!class_exists(ConsoleFormatter::class)) { | ||
$container->removeDefinition('web_server.command.server_log'); | ||
} | ||
} | ||
|
||
private function getPublicDirectory(ContainerBuilder $container) | ||
{ | ||
$kernelProjectDir = $container->getParameter('kernel.project_dir'); | ||
$publicDir = 'public'; | ||
$composerFilePath = $kernelProjectDir.'/composer.json'; | ||
|
||
if (!file_exists($composerFilePath)) { | ||
return $kernelProjectDir.'/'.$publicDir; | ||
} | ||
|
||
$composerConfig = json_decode(file_get_contents($composerFilePath), true); | ||
|
||
if (isset($composerConfig['extra']['public-dir'])) { | ||
$publicDir = $composerConfig['extra']['public-dir']; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we do a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is ok for me what do you think @nicolas-grekas? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we never normalized this var previously: https://github.com/sensiolabs/SensioDistributionBundle/blob/06ec532536f9d6a6049da126c709119176615d45/Composer/ScriptHandler.php#L167-L180 not sure we care, neither we need to. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why should we care? |
||
} | ||
|
||
return $kernelProjectDir.'/'.$publicDir; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "test-composer.json", | ||
"extra": { | ||
"public-dir": "test" | ||
} | ||
} |
There was a problem hiding this comment.
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?There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same opinion here :)