Skip to content

Commit

Permalink
bug #11545 [Bundle][FrameworkBundle] built-in server: exit when docro…
Browse files Browse the repository at this point in the history
…ot does not exist (xabbuh)

This PR was merged into the 2.3 branch.

Discussion
----------

[Bundle][FrameworkBundle] built-in server: exit when docroot does not exist

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #6496
| License       | MIT
| Doc PR        |

When the server:run command is run with an invalid document root
directory (for example, when being in the app directory and not
changing the document root to ../web/), the command crashes on Windows
with a 267 exit code. On Linux, the server starts but just publishes
internal server errors.

Commits
-------

f143254 built-in server: exit when docroot does not exist
  • Loading branch information
fabpot committed Aug 5, 2014
2 parents 24c4984 + f143254 commit e76561d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php
Expand Up @@ -81,6 +81,14 @@ protected function configure()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$documentRoot = $input->getOption('docroot');

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) {
Expand All @@ -96,7 +104,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$output->writeln(sprintf("Server running on <info>http://%s</info>\n", $input->getArgument('address')));

$builder = new ProcessBuilder(array(PHP_BINARY, '-S', $input->getArgument('address'), $router));
$builder->setWorkingDirectory($input->getOption('docroot'));
$builder->setWorkingDirectory($documentRoot);
$builder->setTimeout(null);
$builder->getProcess()->run(function ($type, $buffer) use ($output) {
if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {
Expand Down

0 comments on commit e76561d

Please sign in to comment.