|
0
|
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 |
if ($php = getenv('PHP_PATH')) { |
|
|
37 |
if (!is_executable($php)) { |
|
|
38 |
return false; |
|
|
39 |
} |
|
|
40 |
|
|
|
41 |
return $php; |
|
|
42 |
} |
|
|
43 |
|
|
|
44 |
$suffixes = DIRECTORY_SEPARATOR == '\\' ? (getenv('PATHEXT') ? explode(PATH_SEPARATOR, getenv('PATHEXT')) : array('.exe', '.bat', '.cmd', '.com')) : array(''); |
|
|
45 |
foreach ($suffixes as $suffix) { |
|
|
46 |
if (is_executable($php = PHP_BINDIR.DIRECTORY_SEPARATOR.'php'.$suffix)) { |
|
|
47 |
return $php; |
|
|
48 |
} |
|
|
49 |
} |
|
|
50 |
|
|
|
51 |
if ($php = getenv('PHP_PEAR_PHP_BIN')) { |
|
|
52 |
if (is_executable($php)) { |
|
|
53 |
return $php; |
|
|
54 |
} |
|
|
55 |
} |
|
|
56 |
|
|
|
57 |
return $this->executableFinder->find('php'); |
|
|
58 |
} |
|
|
59 |
} |