Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 819280f

Browse filesBrowse files
committed
bug #12550 [FrameworkBundle] backport #12489 (xabbuh)
This PR was merged into the 2.3 branch. Discussion ---------- [FrameworkBundle] backport #12489 | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | Commits ------- 556eff1 backport #12489
2 parents 4f05279 + 556eff1 commit 819280f
Copy full SHA for 819280f

File tree

Expand file treeCollapse file tree

1 file changed

+29
-13
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+29
-13
lines changed

‎src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php
+29-13Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Component\Console\Input\InputOption;
1616
use Symfony\Component\Console\Input\InputInterface;
1717
use Symfony\Component\Console\Output\OutputInterface;
18+
use Symfony\Component\Process\PhpExecutableFinder;
1819
use Symfony\Component\Process\ProcessBuilder;
1920

2021
/**
@@ -29,7 +30,7 @@ class ServerRunCommand extends ContainerAwareCommand
2930
*/
3031
public function isEnabled()
3132
{
32-
if (PHP_VERSION_ID < 50400) {
33+
if (PHP_VERSION_ID < 50400 || defined('HHVM_VERSION')) {
3334
return false;
3435
}
3536

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

102-
$router = $input->getOption('router') ?: $this
103-
->getContainer()
104-
->get('kernel')
105-
->locateResource(sprintf('@FrameworkBundle/Resources/config/router_%s.php', $env))
106-
;
107-
108-
if (!file_exists($router)) {
109-
$output->writeln(sprintf('<error>The given router script "%s" does not exist</error>', $router));
110-
103+
if (null === $builder = $this->createPhpProcessBuilder($input, $output, $env)) {
111104
return 1;
112105
}
113106

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

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

137127
return $process->getExitCode();
138128
}
129+
130+
private function createPhpProcessBuilder(InputInterface $input, OutputInterface $output, $env)
131+
{
132+
$router = $input->getOption('router') ?: $this
133+
->getContainer()
134+
->get('kernel')
135+
->locateResource(sprintf('@FrameworkBundle/Resources/config/router_%s.php', $env))
136+
;
137+
138+
if (!file_exists($router)) {
139+
$output->writeln(sprintf('<error>The given router script "%s" does not exist</error>', $router));
140+
141+
return;
142+
}
143+
144+
$router = realpath($router);
145+
$finder = new PhpExecutableFinder();
146+
147+
if (false === $binary = $finder->find()) {
148+
$output->writeln('<error>Unable to find PHP binary to run server</error>');
149+
150+
return;
151+
}
152+
153+
return new ProcessBuilder(array($binary, '-S', $input->getArgument('address'), $router));
154+
}
139155
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.