/**
  * Finds The PHP executable.
  *
  * @param bool $includeArgs Whether or not include command arguments
  *
  * @return string|false The PHP executable path or false if it cannot be found
  */
 public function find($includeArgs = true)
 {
     // HHVM support
     if (defined('HHVM_VERSION')) {
         return (false !== ($hhvm = getenv('PHP_BINARY')) ? $hhvm : 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;
     }
     if ($php = getenv('PHP_PATH')) {
         if (!is_executable($php)) {
             return false;
         }
         return $php;
     }
     if ($php = getenv('PHP_PEAR_PHP_BIN')) {
         if (is_executable($php)) {
             return $php;
         }
     }
     $dirs = array(PHP_BINDIR);
     if (Symfony_Process_ProcessUtils::isWindows()) {
         $dirs[] = 'C:\\xampp\\php\\';
     }
     return $this->executableFinder->find('php', false, $dirs);
 }
 /**
  * Finds an executable by name.
  *
  * @param string $name      The executable name (without the extension)
  * @param string $default   The default to return if no executable is found
  * @param array  $extraDirs Additional dirs to check into
  *
  * @return string The executable path or default value
  */
 public function find($name, $default = null, array $extraDirs = array())
 {
     if (ini_get('open_basedir')) {
         $searchPath = explode(PATH_SEPARATOR, ini_get('open_basedir'));
         $dirs = array();
         foreach ($searchPath as $path) {
             if (@is_dir($path)) {
                 $dirs[] = $path;
             } else {
                 if (basename($path) == $name && is_executable($path)) {
                     return $path;
                 }
             }
         }
     } else {
         $dirs = array_merge(explode(PATH_SEPARATOR, getenv('PATH') ? getenv('PATH') : getenv('Path')), $extraDirs);
     }
     $suffixes = array('');
     if (Symfony_Process_ProcessUtils::isWindows()) {
         $pathExt = getenv('PATHEXT');
         $suffixes = $pathExt ? explode(PATH_SEPARATOR, $pathExt) : $this->suffixes;
     }
     foreach ($suffixes as $suffix) {
         foreach ($dirs as $dir) {
             if (is_file($file = $dir . DIRECTORY_SEPARATOR . $name . $suffix) && (Symfony_Process_ProcessUtils::isWindows() || is_executable($file))) {
                 return $file;
             }
         }
     }
     return $default;
 }
예제 #3
0
 /**
  * Updates the status of the process, reads pipes.
  *
  * @param bool $blocking Whether to use a blocking read call.
  */
 protected function updateStatus($blocking)
 {
     if (self::STATUS_STARTED !== $this->status) {
         return;
     }
     $this->processInformation = proc_get_status($this->process);
     $this->captureExitCode();
     $this->readPipes($blocking, Symfony_Process_ProcessUtils::isWindows() ? !$this->processInformation['running'] : true);
     if (!$this->processInformation['running']) {
         $this->close();
     }
 }