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 60f38de

Browse filesBrowse files
committed
bug #12489 [2.5][FrameworkBundle] Fix server run in case the router script does not exist (romainneutron)
This PR was merged into the 2.5 branch. Discussion ---------- [2.5][FrameworkBundle] Fix server run in case the router script does not exist | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT I've also added the use of `Process\PhpExecutableFinder` Commits ------- 1a79859 [FrameworkBundle] Fix server run in case the router script does not exist
2 parents e041ff4 + 1a79859 commit 60f38de
Copy full SHA for 60f38de

File tree

Expand file treeCollapse file tree

1 file changed

+20
-3
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+20
-3
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php
+20-3Lines changed: 20 additions & 3 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
/**
@@ -82,6 +83,12 @@ protected function configure()
8283
*/
8384
protected function execute(InputInterface $input, OutputInterface $output)
8485
{
86+
if (defined('HHVM_VERSION')) {
87+
$output->writeln('<error>This command is not supported on HHVM.</error>');
88+
89+
return 1;
90+
}
91+
8592
$documentRoot = $input->getOption('docroot');
8693

8794
if (!is_dir($documentRoot)) {
@@ -99,7 +106,10 @@ protected function execute(InputInterface $input, OutputInterface $output)
99106
$output->writeln(sprintf("Server running on <info>http://%s</info>\n", $input->getArgument('address')));
100107
$output->writeln('Quit the server with CONTROL-C.');
101108

102-
$builder = $this->createPhpProcessBuilder($input, $output, $env);
109+
if (null === $builder = $this->createPhpProcessBuilder($input, $output, $env)) {
110+
return 1;
111+
}
112+
103113
$builder->setWorkingDirectory($documentRoot);
104114
$builder->setTimeout(null);
105115
$process = $builder->getProcess();
@@ -137,11 +147,18 @@ private function createPhpProcessBuilder(InputInterface $input, OutputInterface
137147
if (!file_exists($router)) {
138148
$output->writeln(sprintf('<error>The given router script "%s" does not exist</error>', $router));
139149

140-
return 1;
150+
return;
141151
}
142152

143153
$router = realpath($router);
154+
$finder = new PhpExecutableFinder();
155+
156+
if (false === $binary = $finder->find()) {
157+
$output->writeln('<error>Unable to find PHP binary to run server</error>');
158+
159+
return;
160+
}
144161

145-
return new ProcessBuilder(array(PHP_BINARY, '-S', $input->getArgument('address'), $router));
162+
return new ProcessBuilder(array($binary, '-S', $input->getArgument('address'), $router));
146163
}
147164
}

0 commit comments

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