8000 bug #23535 Make server:* commands work out of the box with the public… · symfony/symfony@c75d0c5 · GitHub
[go: up one dir, main page]

Skip to content

Commit c75d0c5

Browse files
committed
bug #23535 Make server:* commands work out of the box with the public/ root dir (fabpot)
This PR was squashed before being merged into the 3.3 branch (closes #23535). Discussion ---------- Make server:* commands work out of the box with the public/ root dir | Q | A | ------------- | --- | Branch? | 3.3 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a The first commit removes code that is not needed as the WebserverConfig class already throws the exact same error and the display is exactly the same in that case. The second commit adds support for `public/` along side `web/`. Commits ------- 34c8566 [WebServerBundle] allowed public/ root directory to be auto-discovered along side web/ bc6b57c [WebServerBundle] remove duplicate code
2 parents 0d72e82 + 34c8566 commit c75d0c5

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

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

Lines changed: 6 additions & 6 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.');
@@ -97,12 +103,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
97103
$documentRoot = $this->documentRoot;
98104
}
99105

100-
if (!is_dir($documentRoot)) {
101-
$io->error(sprintf('The document root directory "%s" does not exist.', $documentRoot));
102-
103-
return 1;
104-
}
105-
106106
if (!$env = $this->environment) {
107107
if ($input->hasOption('env') && !$env = $input->getOption('env')) {
108108
$io->error('The environment must be either passed as second argument of the constructor or through the "--env" input option.');

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

Lines changed: 6 additions & 6 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.');
@@ -109,12 +115,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
109115
$documentRoot = $this->documentRoot;
110116
}
111117

112-
if (!is_dir($documentRoot)) {
113-
$io->error(sprintf('The document root directory "%s" does not exist.', $documentRoot));
114-
115-
return 1;
116-
}
117-
118118
if (!$env = $this->environment) {
119119
if ($input->hasOption('env') && !$env = $input->getOption('env')) {
120120
$io->error('The environment must be either passed as second argument of the constructor or through the "--env" 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)
0