8000 [FrameworkBundle] backport #12489 by xabbuh · Pull Request #12550 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[FrameworkBundle] backport #12489 #12550

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

Merged
merged 1 commit into from
Nov 28, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 29 additions & 13 deletions src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -29,7 +30,7 @@ class ServerRunCommand extends ContainerAwareCommand
*/
public function isEnabled()
{
if (PHP_VERSION_ID < 50400) {
if (PHP_VERSION_ID < 50400 || defined('HHVM_VERSION')) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has initially been done in #10786 for 2.4 and above.

return false;
}

Expand Down Expand Up @@ -99,24 +100,13 @@ protected function execute(InputInterface $input, OutputInterface $output)
$output->writeln('<error>Running PHP built-in server in production environment is NOT recommended!</error>');
}

$router = $input->getOption('router') ?: $this
->getContainer()
->get('kernel')
->locateResource(sprintf('@FrameworkBundle/Resources/config/router_%s.php', $env))
;

if (!file_exists($router)) {
$output->writeln(sprintf('<error>The given router script "%s" does not exist</error>', $router));

if (null === $builder = $this->createPhpProcessBuilder($input, $output, $env)) {
return 1;
}

$router = realpath($router);

$output->writeln(sprintf("Server running on <info>http://%s</info>\n", $input->getArgument('address')));
$output->writeln('Quit the server with CONTROL-C.');

$builder = new ProcessBuilder(array(PHP_BINARY, '-S', $input->getArgument('address'), $router));
$builder->setWorkingDirectory($documentRoot);
$builder->setTimeout(null);
$process = $builder->getProcess();
Expand All @@ -136,4 +126,30 @@ protected function execute(InputInterface $input, OutputInterface $output)

return $process->getExitCode();
}

private function createPhpProcessBuilder(InputInterface $input, OutputInterface $output, $env)
{
$router = $input->getOption('router') ?: $this
->getContainer()
->get('kernel')
->locateResource(sprintf('@FrameworkBundle/Resources/config/router_%s.php', $env))
;

if (!file_exists($router)) {
$output->writeln(sprintf('<error>The given router script "%s" does not exist</error>', $router));

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($binary, '-S', $input->getArgument('address'), $router));
}
}
0