diff --git a/PhpExecutableFinder.php b/PhpExecutableFinder.php index f8f57cc5..6dbe5bc8 100644 --- a/PhpExecutableFinder.php +++ b/PhpExecutableFinder.php @@ -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;