diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php index 63588d5264..3535167910 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php @@ -81,6 +81,14 @@ EOF */ protected function execute(InputInterface $input, OutputInterface $output) { + $documentRoot = $input->getOption('docroot'); + + if (!is_dir($documentRoot)) { + $output->writeln(sprintf('The given document root directory "%s" does not exist', $documentRoot)); + + return 1; + } + $env = $this->getContainer()->getParameter('kernel.environment'); if ('prod' === $env) { @@ -96,7 +104,7 @@ EOF $output->writeln(sprintf("Server running on http://%s\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()) {