added knp-snappy package for Jerry's UB04 work
[openemr.git] / vendor / symfony / process / PhpExecutableFinder.php
blobdb31cc1b3ce8b2c354ef975c45049f96279ee7c5
1 <?php
3 /*
4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Process;
14 /**
15 * An executable finder specifically designed for the PHP executable.
17 * @author Fabien Potencier <fabien@symfony.com>
18 * @author Johannes M. Schmitt <schmittjoh@gmail.com>
20 class PhpExecutableFinder
22 private $executableFinder;
24 public function __construct()
26 $this->executableFinder = new ExecutableFinder();
29 /**
30 * Finds The PHP executable.
32 * @param bool $includeArgs Whether or not include command arguments
34 * @return string|false The PHP executable path or false if it cannot be found
36 public function find($includeArgs = true)
38 $args = $this->findArguments();
39 $args = $includeArgs && $args ? ' '.implode(' ', $args) : '';
41 // HHVM support
42 if (defined('HHVM_VERSION')) {
43 return (getenv('PHP_BINARY') ?: PHP_BINARY).$args;
46 // PHP_BINARY return the current sapi executable
47 if (PHP_BINARY && in_array(PHP_SAPI, array('cli', 'cli-server', 'phpdbg')) && is_file(PHP_BINARY)) {
48 return PHP_BINARY.$args;
51 if ($php = getenv('PHP_PATH')) {
52 if (!is_executable($php)) {
53 return false;
56 return $php;
59 if ($php = getenv('PHP_PEAR_PHP_BIN')) {
60 if (is_executable($php)) {
61 return $php;
65 $dirs = array(PHP_BINDIR);
66 if ('\\' === DIRECTORY_SEPARATOR) {
67 $dirs[] = 'C:\xampp\php\\';
70 return $this->executableFinder->find('php', false, $dirs);
73 /**
74 * Finds the PHP executable arguments.
76 * @return array The PHP executable arguments
78 public function findArguments()
80 $arguments = array();
82 if (defined('HHVM_VERSION')) {
83 $arguments[] = '--php';
84 } elseif ('phpdbg' === PHP_SAPI) {
85 $arguments[] = '-qrr';
88 return $arguments;