Skip to content

Commit 546d606

Browse files
committed
Check for php-cgi on instantiation, and die with message if unable to collect version information.
1 parent 409365a commit 546d606

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/ExerciseRunner/CgiRunner.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ class CgiRunner implements ExerciseRunnerInterface
4343
*/
4444
public function __construct(CgiExercise $exercise, EventDispatcher $eventDispatcher)
4545
{
46+
// Suppress shell output. Anything non-zero is a failure.
47+
@system('php-cgi --version > /dev/null 2>&1', $failedToRun);
48+
if ($failedToRun) {
49+
die('Could not load php-cgi binary. Please install php-cgi using your package manager.' . PHP_EOL);
50+
}
4651
$this->eventDispatcher = $eventDispatcher;
4752
$this->exercise = $exercise;
4853
}

0 commit comments

Comments
 (0)