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:
Fabien Potencier 2014-11-21 16:58:20 +01:00
commit b3be900ece

View File

@ -33,7 +33,7 @@ class ServerStartCommand extends ServerCommand
$this
->setDefinition(array(
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'),
))
->setName('server:start')
@ -83,6 +83,18 @@ EOF
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');
if ('prod' === $env) {
@ -111,7 +123,7 @@ EOF
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;
}