ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
PhpExecutableFinder.php
Go to the documentation of this file.
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
13
21{
23
24 public function __construct()
25 {
26 $this->executableFinder = new ExecutableFinder();
27 }
28
36 public function find($includeArgs = true)
37 {
38 $args = $this->findArguments();
39 $args = $includeArgs && $args ? ' '.implode(' ', $args) : '';
40
41 // HHVM support
42 if (defined('HHVM_VERSION')) {
43 return (getenv('PHP_BINARY') ?: PHP_BINARY).$args;
44 }
45
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;
49 }
50
51 if ($php = getenv('PHP_PATH')) {
52 if (!is_executable($php)) {
53 return false;
54 }
55
56 return $php;
57 }
58
59 if ($php = getenv('PHP_PEAR_PHP_BIN')) {
60 if (is_executable($php)) {
61 return $php;
62 }
63 }
64
65 $dirs = array(PHP_BINDIR);
66 if ('\\' === DIRECTORY_SEPARATOR) {
67 $dirs[] = 'C:\xampp\php\\';
68 }
69
70 return $this->executableFinder->find('php', false, $dirs);
71 }
72
78 public function findArguments()
79 {
80 $arguments = array();
81
82 if (defined('HHVM_VERSION')) {
83 $arguments[] = '--php';
84 } elseif ('phpdbg' === PHP_SAPI) {
85 $arguments[] = '-qrr';
86 }
87
88 return $arguments;
89 }
90}
An exception for terminatinating execution or to throw for unit testing.
An executable finder specifically designed for the PHP executable.
find($includeArgs=true)
Finds The PHP executable.
findArguments()
Finds the PHP executable arguments.
$php
Definition: flush.php:22
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'
Definition: bootstrap.php:27