Skip to content

Commit 34c8566

Browse files
committed
[WebServerBundle] allowed public/ root directory to be auto-discovered along side web/
1 parent bc6b57c commit 34c8566

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

src/Symfony/Bundle/WebServerBundle/Command/ServerRunCommand.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ protected function execute(InputInterface $input, OutputInterface $output)
8888
{
8989
$io = new SymfonyStyle($input, $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output);
9090

91+
// deprecated, logic to be removed in 4.0
92+
// this allows the commands to work out of the box with web/ and public/
93+
if ($this->documentRoot && !is_dir($this->documentRoot) && is_dir(dirname($this->documentRoot).'/web')) {
94+
$this->documentRoot = dirname($this->documentRoot).'/web';
95+
}
96+
9197
if (null === $documentRoot = $input->getOption('docroot')) {
9298
if (!$this->documentRoot) {
9399
$io->error('The document root directory must be either passed as first argument of the constructor or through the "--docroot" input option.');

src/Symfony/Bundle/WebServerBundle/Command/ServerStartCommand.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,12 @@ protected function execute(InputInterface $input, OutputInterface $output)
100100
return 1;
101101
}
102102

103+
// deprecated, logic to be removed in 4.0
104+
// this allows the commands to work out of the box with web/ and public/
105+
if ($this->documentRoot && !is_dir($this->documentRoot) && is_dir(dirname($this->documentRoot).'/web')) {
106+
$this->documentRoot = dirname($this->documentRoot).'/web';
107+
}
108+
103109
if (null === $documentRoot = $input->getOption('docroot')) {
104110
if (!$this->documentRoot) {
105111
$io->error('The document root directory must be either passed as first argument of the constructor or through the "docroot" input option.');

src/Symfony/Bundle/WebServerBundle/Resources/config/webserver.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
<defaults public="false" />
99

1010
<service id="web_server.command.server_run" class="Symfony\Bundle\WebServerBundle\Command\ServerRunCommand">
11-
<argument>%kernel.project_dir%/web</argument>
11+
<argument>%kernel.project_dir%/public</argument>
1212
<argument>%kernel.environment%</argument>
1313
<tag name="console.command" />
1414
</service>
1515

1616
<service id="web_server.command.server_start" class="Symfony\Bundle\WebServerBundle\Command\ServerStartCommand">
17-
<argument>%kernel.project_dir%/web</argument>
17+
<argument>%kernel.project_dir%/public</argument>
1818
<argument>%kernel.environment%</argument>
1919
<tag name="console.command" />
2020
</service>

0 commit comments

Comments
 (0)