1 | <?php |
---|
2 | |
---|
3 | /* |
---|
4 | * This file is part of the Symfony package. |
---|
5 | * |
---|
6 | * (c) Fabien Potencier <fabien@symfony.com> |
---|
7 | * |
---|
8 | * For the full copyright and license information, please view the LICENSE |
---|
9 | * file that was distributed with this source code. |
---|
10 | */ |
---|
11 | |
---|
12 | namespace Symfony\Component\Process; |
---|
13 | |
---|
14 | /** |
---|
15 | * An executable finder specifically designed for the PHP executable. |
---|
16 | * |
---|
17 | * @author Fabien Potencier <fabien@symfony.com> |
---|
18 | * @author Johannes M. Schmitt <schmittjoh@gmail.com> |
---|
19 | */ |
---|
20 | class PhpExecutableFinder |
---|
21 | { |
---|
22 | private $executableFinder; |
---|
23 | |
---|
24 | public function __construct() |
---|
25 | { |
---|
26 | $this->executableFinder = new ExecutableFinder(); |
---|
27 | } |
---|
28 | |
---|
29 | /** |
---|
30 | * Finds The PHP executable. |
---|
31 | * |
---|
32 | * @return string|false The PHP executable path or false if it cannot be found |
---|
33 | */ |
---|
34 | public function find() |
---|
35 | { |
---|
36 | // PHP_BINARY return the current sapi executable |
---|
37 | if (defined('PHP_BINARY') && PHP_BINARY && ('cli' === PHP_SAPI)) { |
---|
38 | return PHP_BINARY; |
---|
39 | } |
---|
40 | |
---|
41 | if ($php = getenv('PHP_PATH')) { |
---|
42 | if (!is_executable($php)) { |
---|
43 | return false; |
---|
44 | } |
---|
45 | |
---|
46 | return $php; |
---|
47 | } |
---|
48 | |
---|
49 | if ($php = getenv('PHP_PEAR_PHP_BIN')) { |
---|
50 | if (is_executable($php)) { |
---|
51 | return $php; |
---|
52 | } |
---|
53 | } |
---|
54 | |
---|
55 | $dirs = array(PHP_BINDIR); |
---|
56 | if (defined('PHP_WINDOWS_VERSION_BUILD')) { |
---|
57 | $dirs[] = 'C:\xampp\php\\'; |
---|
58 | } |
---|
59 | |
---|
60 | return $this->executableFinder->find('php', false, $dirs); |
---|
61 | } |
---|
62 | } |
---|