diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php
index 925831e726d88..64957858c1e5a 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php
@@ -15,6 +15,7 @@
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
+use Symfony\Component\Process\PhpExecutableFinder;
use Symfony\Component\Process\ProcessBuilder;
/**
@@ -82,6 +83,12 @@ protected function configure()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
+ if (defined('HHVM_VERSION')) {
+ $output->writeln('This command is not supported on HHVM.');
+
+ return 1;
+ }
+
$documentRoot = $input->getOption('docroot');
if (!is_dir($documentRoot)) {
@@ -99,7 +106,10 @@ protected function execute(InputInterface $input, OutputInterface $output)
$output->writeln(sprintf("Server running on http://%s\n", $input->getArgument('address')));
$output->writeln('Quit the server with CONTROL-C.');
- $builder = $this->createPhpProcessBuilder($input, $output, $env);
+ if (null === $builder = $this->createPhpProcessBuilder($input, $output, $env)) {
+ return 1;
+ }
+
$builder->setWorkingDirectory($documentRoot);
$builder->setTimeout(null);
$process = $builder->getProcess();
@@ -137,11 +147,18 @@ private function createPhpProcessBuilder(InputInterface $input, OutputInterface
if (!file_exists($router)) {
$output->writeln(sprintf('The given router script "%s" does not exist', $router));
- return 1;
+ return;
}
$router = realpath($router);
+ $finder = new PhpExecutableFinder();
+
+ if (false === $binary = $finder->find()) {
+ $output->writeln('Unable to find PHP binary to run server');
+
+ return;
+ }
- return new ProcessBuilder(array(PHP_BINARY, '-S', $input->getArgument('address'), $router));
+ return new ProcessBuilder(array($binary, '-S', $input->getArgument('address'), $router));
}
}