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
25class 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}
An exception for terminatinating execution or to throw for unit testing.
RuntimeException for the Process Component.
An executable finder specifically designed for the PHP executable.
PhpProcess runs a PHP script in an independent process.
Definition: PhpProcess.php:26
__construct($script, $cwd=null, array $env=null, $timeout=60, array $options=array())
Constructor.
Definition: PhpProcess.php:36
setPhpBinary($php)
Sets the path to the PHP binary to use.
Definition: PhpProcess.php:62
start(callable $callback=null)
{Starts the process and returns after writing the input to STDIN.This method blocks until all STDIN d...
Definition: PhpProcess.php:70
Process is a thin wrapper around proc_* functions to easily start independent PHP processes.
Definition: Process.php:31
setCommandLine($commandline)
Sets the command line to be executed.
Definition: Process.php:897
getCommandLine()
Gets the command line to be executed.
Definition: Process.php:885
$php
Definition: flush.php:22
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file