-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[2.5][FrameworkBundle] Fix server run in case the router script does not exist #12489
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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('<error>This command is not supported on HHVM.</error>'); | ||
|
||
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 <info>http://%s</info>\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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you should probably display an error message There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. An error message is already printed in |
||
} | ||
|
||
$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('<error>The given router script "%s" does not exist</error>', $router)); | ||
|
||
return 1; | ||
return; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In current implementation, if
I prefer to return |
||
} | ||
|
||
$router = realpath($router); | ||
$finder = new PhpExecutableFinder(); | ||
|
||
if (false === $binary = $finder->find()) { | ||
$output->writeln('<error>Unable to find PHP binary to run server</error>'); | ||
|
||
return; | ||
} | ||
|
||
return new ProcessBuilder(array(PHP_BINARY, '-S', $input->getArgument('address'), $router)); | ||
return new ProcessBuilder(array($binary, '-S', $input->getArgument('address'), $router)); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is useless, given that the command is disabled entirely on HHVM, same than on PHP 5.3 (see line 33)