Skip to content
Closed
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
15 changes: 9 additions & 6 deletions PhpExecutableFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,22 @@ public function find($includeArgs = true)
return (getenv('PHP_BINARY') ?: PHP_BINARY).($includeArgs ? ' '.implode(' ', $this->findArguments()) : '');
}

// PHP_BINARY return the current sapi executable
if (defined('PHP_BINARY') && PHP_BINARY && in_array(PHP_SAPI, array('cli', 'cli-server')) && is_file(PHP_BINARY)) {
return PHP_BINARY;
}

// Check PHP PATH environment variable
if ($php = getenv('PHP_PATH')) {
if (!is_executable($php)) {

// check if PHP_PATH is executable (even with options ex: path/to/php -c something)
if (!is_executable(substr($php, 0, strrpos($php, ' ')))){
return false;
}

return $php;
}

// PHP_BINARY return the current sapi executable
if (defined('PHP_BINARY') && PHP_BINARY && in_array(PHP_SAPI, array('cli', 'cli-server')) && is_file(PHP_BINARY)) {
return PHP_BINARY;
}

if ($php = getenv('PHP_PEAR_PHP_BIN')) {
if (is_executable($php)) {
return $php;
Expand Down