feature #12538 [FrameworkBundle] be smarter when guessing the document root (xabbuh)
This PR was merged into the 2.6 branch.
Discussion
----------
[FrameworkBundle] be smarter when guessing the document root
| Q | A
| ------------- | ---
| Bug fix? | no
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #12524
| License | MIT
| Doc PR |
Commits
-------
83d768d
be smarter when guessing the document root
This commit is contained in:
commit
b3be900ece
@ -33,7 +33,7 @@ class ServerStartCommand extends ServerCommand
|
|||||||
$this
|
$this
|
||||||
->setDefinition(array(
|
->setDefinition(array(
|
||||||
new InputArgument('address', InputArgument::OPTIONAL, 'Address:port', '127.0.0.1:8000'),
|
new InputArgument('address', InputArgument::OPTIONAL, 'Address:port', '127.0.0.1:8000'),
|
||||||
new InputOption('docroot', 'd', InputOption::VALUE_REQUIRED, 'Document root', 'web/'),
|
new InputOption('docroot', 'd', InputOption::VALUE_REQUIRED, 'Document root', null),
|
||||||
new InputOption('router', 'r', InputOption::VALUE_REQUIRED, 'Path to custom router script'),
|
new InputOption('router', 'r', InputOption::VALUE_REQUIRED, 'Path to custom router script'),
|
||||||
))
|
))
|
||||||
->setName('server:start')
|
->setName('server:start')
|
||||||
@ -83,6 +83,18 @@ EOF
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$documentRoot = $input->getOption('docroot');
|
||||||
|
|
||||||
|
if (null === $documentRoot) {
|
||||||
|
$documentRoot = $this->getContainer()->getParameter('kernel.root_dir').'/../web';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_dir($documentRoot)) {
|
||||||
|
$output->writeln(sprintf('<error>The given document root directory "%s" does not exist</error>', $documentRoot));
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
$env = $this->getContainer()->getParameter('kernel.environment');
|
$env = $this->getContainer()->getParameter('kernel.environment');
|
||||||
|
|
||||||
if ('prod' === $env) {
|
if ('prod' === $env) {
|
||||||
@ -111,7 +123,7 @@ EOF
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null === $process = $this->createServerProcess($output, $address, $input->getOption('docroot'), $input->getOption('router'), $env, null)) {
|
if (null === $process = $this->createServerProcess($output, $address, $documentRoot, $input->getOption('router'), $env, null)) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user