ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
PhpProcess.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 
15 
25 class PhpProcess extends Process
26 {
36  public function __construct($script, $cwd = null, array $env = null, $timeout = 60, array $options = array())
37  {
38  $executableFinder = new PhpExecutableFinder();
39  if (false === $php = $executableFinder->find()) {
40  $php = null;
41  }
42  if ('phpdbg' === PHP_SAPI) {
43  $file = tempnam(sys_get_temp_dir(), 'dbg');
44  file_put_contents($file, $script);
45  register_shutdown_function('unlink', $file);
46  $php .= ' '.ProcessUtils::escapeArgument($file);
47  $script = null;
48  }
49  if ('\\' !== DIRECTORY_SEPARATOR && null !== $php) {
50  // exec is mandatory to deal with sending a signal to the process
51  // see https://github.com/symfony/symfony/issues/5030 about prepending
52  // command with exec
53  $php = 'exec '.$php;
54  }
55 
56  parent::__construct($php, $cwd, $env, $script, $timeout, $options);
57  }
58 
62  public function setPhpBinary($php)
63  {
64  $this->setCommandLine($php);
65  }
66 
70  public function start(callable $callback = null)
71  {
72  if (null === $this->getCommandLine()) {
73  throw new RuntimeException('Unable to find the PHP executable.');
74  }
75 
76  parent::start($callback);
77  }
78 }
start(callable $callback=null)
{}
Definition: PhpProcess.php:70
__construct($script, $cwd=null, array $env=null, $timeout=60, array $options=array())
Constructor.
Definition: PhpProcess.php:36
An executable finder specifically designed for the PHP executable.
setCommandLine($commandline)
Sets the command line to be executed.
Definition: Process.php:897
Create styles array
The data for the language used.
getCommandLine()
Gets the command line to be executed.
Definition: Process.php:885
Process is a thin wrapper around proc_* functions to easily start independent PHP processes...
Definition: Process.php:30
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
setPhpBinary($php)
Sets the path to the PHP binary to use.
Definition: PhpProcess.php:62
$php
Definition: flush.php:22
PhpProcess runs a PHP script in an independent process.
Definition: PhpProcess.php:25