Exception
1 year ago
Pipes
1 year ago
ExecutableFinder.php
1 year ago
InputStream.php
1 year ago
LICENSE
1 year ago
PhpExecutableFinder.php
1 year ago
PhpProcess.php
1 year ago
Process.php
3 months ago
ProcessUtils.php
1 year ago
README.md
1 year ago
PhpExecutableFinder.php
82 lines
| 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 | namespace Symfony\Component\Process; |
| 12 | |
| 13 | /** |
| 14 | * An executable finder specifically designed for the PHP executable. |
| 15 | * |
| 16 | * @author Fabien Potencier <fabien@symfony.com> |
| 17 | * @author Johannes M. Schmitt <schmittjoh@gmail.com> |
| 18 | */ |
| 19 | class PhpExecutableFinder |
| 20 | { |
| 21 | private $executableFinder; |
| 22 | public function __construct() |
| 23 | { |
| 24 | $this->executableFinder = new \Symfony\Component\Process\ExecutableFinder(); |
| 25 | } |
| 26 | /** |
| 27 | * Finds The PHP executable. |
| 28 | * |
| 29 | * @return string|false |
| 30 | */ |
| 31 | public function find(bool $includeArgs = \true) |
| 32 | { |
| 33 | if ($php = getenv('PHP_BINARY')) { |
| 34 | if (!is_executable($php) && !($php = $this->executableFinder->find($php))) { |
| 35 | return \false; |
| 36 | } |
| 37 | if (@is_dir($php)) { |
| 38 | return \false; |
| 39 | } |
| 40 | return $php; |
| 41 | } |
| 42 | $args = $this->findArguments(); |
| 43 | $args = $includeArgs && $args ? ' ' . implode(' ', $args) : ''; |
| 44 | // PHP_BINARY return the current sapi executable |
| 45 | if (\PHP_BINARY && \in_array(\PHP_SAPI, ['cli', 'cli-server', 'phpdbg'], \true)) { |
| 46 | return \PHP_BINARY . $args; |
| 47 | } |
| 48 | if ($php = getenv('PHP_PATH')) { |
| 49 | if (!@is_executable($php) || @is_dir($php)) { |
| 50 | return \false; |
| 51 | } |
| 52 | return $php; |
| 53 | } |
| 54 | if ($php = getenv('PHP_PEAR_PHP_BIN')) { |
| 55 | if (@is_executable($php) && !@is_dir($php)) { |
| 56 | return $php; |
| 57 | } |
| 58 | } |
| 59 | if (@is_executable($php = \PHP_BINDIR . ('\\' === \DIRECTORY_SEPARATOR ? '\\php.exe' : '/php')) && !@is_dir($php)) { |
| 60 | return $php; |
| 61 | } |
| 62 | $dirs = [\PHP_BINDIR]; |
| 63 | if ('\\' === \DIRECTORY_SEPARATOR) { |
| 64 | $dirs[] = 'C:\\xampp\\php\\'; |
| 65 | } |
| 66 | return $this->executableFinder->find('php', \false, $dirs); |
| 67 | } |
| 68 | /** |
| 69 | * Finds the PHP executable arguments. |
| 70 | * |
| 71 | * @return array |
| 72 | */ |
| 73 | public function findArguments() |
| 74 | { |
| 75 | $arguments = []; |
| 76 | if ('phpdbg' === \PHP_SAPI) { |
| 77 | $arguments[] = '-qrr'; |
| 78 | } |
| 79 | return $arguments; |
| 80 | } |
| 81 | } |
| 82 |