[WebServerBundle] allowed public/ root directory to be auto-discovered along side web/

This commit is contained in:
Fabien Potencier 2017-07-16 14:39:52 +02:00
parent bc6b57c208
commit 34c8566be1
3 changed files with 14 additions and 2 deletions

View File

@ -88,6 +88,12 @@ EOF
{
$io = new SymfonyStyle($input, $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output);
// deprecated, logic to be removed in 4.0
// this allows the commands to work out of the box with web/ and public/
if ($this->documentRoot && !is_dir($this->documentRoot) && is_dir(dirname($this->documentRoot).'/web')) {
$this->documentRoot = dirname($this->documentRoot).'/web';
}
if (null === $documentRoot = $input->getOption('docroot')) {
if (!$this->documentRoot) {
$io->error('The document root directory must be either passed as first argument of the constructor or through the "--docroot" input option.');

View File

@ -100,6 +100,12 @@ EOF
return 1;
}
// deprecated, logic to be removed in 4.0
// this allows the commands to work out of the box with web/ and public/
if ($this->documentRoot && !is_dir($this->documentRoot) && is_dir(dirname($this->documentRoot).'/web')) {
$this->documentRoot = dirname($this->documentRoot).'/web';
}
if (null === $documentRoot = $input->getOption('docroot')) {
if (!$this->documentRoot) {
$io->error('The document root directory must be either passed as first argument of the constructor or through the "docroot" input option.');

View File

@ -8,13 +8,13 @@
<defaults public="false" />
<service id="web_server.command.server_run" class="Symfony\Bundle\WebServerBundle\Command\ServerRunCommand">
<argument>%kernel.project_dir%/web</argument>
<argument>%kernel.project_dir%/public</argument>
<argument>%kernel.environment%</argument>
<tag name="console.command" />
</service>
<service id="web_server.command.server_start" class="Symfony\Bundle\WebServerBundle\Command\ServerStartCommand">
<argument>%kernel.project_dir%/web</argument>
<argument>%kernel.project_dir%/public</argument>
<argument>%kernel.environment%</argument>
<tag name="console.command" />
</service>