PhpProcess runs a PHP script in an independent process.
$p = new PhpProcess('<?php echo "foo"; ?>'); $p->run(); print $p->getOutput()."\n";
@author Fabien Potencier <fabien@symfony.com>
@api
Expanded class hierarchy of PhpProcess
class PhpProcess extends Process {
private $executableFinder;
/**
* Constructor.
*
* @param string $script The PHP script to run (as a string)
* @param string $cwd The working directory
* @param array $env The environment variables
* @param integer $timeout The timeout in seconds
* @param array $options An array of options for proc_open
*
* @api
*/
public function __construct($script, $cwd = null, array $env = array(), $timeout = 60, array $options = array()) {
parent::__construct(null, $cwd, $env, $script, $timeout, $options);
$this->executableFinder = new PhpExecutableFinder();
}
/**
* Sets the path to the PHP binary to use.
*
* @api
*/
public function setPhpBinary($php) {
$this
->setCommandLine($php);
}
/**
* Runs the process.
*
* @param Closure|string|array $callback A PHP callback to run whenever there is some
* output available on STDOUT or STDERR
*
* @return integer The exit status code
*
* @api
*/
public function run($callback = null) {
if (null === $this
->getCommandLine()) {
if (false === ($php = $this->executableFinder
->find())) {
throw new \RuntimeException('Unable to find the PHP executable.');
}
$this
->setCommandLine($php);
}
return parent::run($callback);
}
}
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PhpProcess:: |
private | property | ||
PhpProcess:: |
public | function |
Runs the process. Overrides Process:: |
|
PhpProcess:: |
public | function | Sets the path to the PHP binary to use. | |
PhpProcess:: |
public | function |
Constructor. Overrides Process:: |
|
Process:: |
private | property | ||
Process:: |
private | property | ||
Process:: |
private | property | ||
Process:: |
private | property | ||
Process:: |
private | property | ||
Process:: |
public static | property | Exit codes translation table. | |
Process:: |
private | property | ||
Process:: |
private | property | ||
Process:: |
private | property | ||
Process:: |
private | property | ||
Process:: |
private | property | ||
Process:: |
private | property | ||
Process:: |
private | property | ||
Process:: |
private | property | ||
Process:: |
private | property | ||
Process:: |
private | property | ||
Process:: |
private | property | ||
Process:: |
private | property | ||
Process:: |
public | function | ||
Process:: |
public | function | ||
Process:: |
protected | function | Builds up the callback used by wait(). | |
Process:: |
constant | |||
Process:: |
public | function | ||
Process:: |
public | function | ||
Process:: |
public | function | ||
Process:: |
public | function | Returns the current error output of the process (STDERR). | |
Process:: |
public | function | Returns the exit code returned by the process. | |
Process:: |
public | function | Returns a string representation for the exit code returned by the process. | |
Process:: |
public | function | ||
Process:: |
public | function | Returns the current output of the process (STDOUT). | |
Process:: |
public | function | ||
Process:: |
public | function | Returns the number of the signal that caused the child process to stop its execution | |
Process:: |
public | function | Returns the number of the signal that caused the child process to terminate its execution. | |
Process:: |
public | function | ||
Process:: |
public | function | ||
Process:: |
public | function | Returns true if the child process has been terminated by an uncaught signal. | |
Process:: |
public | function | Returns true if the child process has been stopped by a signal. | |
Process:: |
public | function | Checks if the process is currently running. | |
Process:: |
public | function | Checks if the process ended successfully. | |
Process:: |
constant | |||
Process:: |
private | function | Handles the windows file handles fallbacks | |
Process:: |
public | function | ||
Process:: |
public | function | ||
Process:: |
public | function | ||
Process:: |
public | function | ||
Process:: |
public | function | ||
Process:: |
public | function | Sets the process timeout. | |
Process:: |
public | function | ||
Process:: |
public | function | Starts the process and returns after sending the STDIN. | |
Process:: |
constant | |||
Process:: |
constant | |||
Process:: |
constant | |||
Process:: |
constant | |||
Process:: |
constant | |||
Process:: |
constant | |||
Process:: |
public | function | Stops the process. | |
Process:: |
protected | function | ||
Process:: |
protected | function | ||
Process:: |
protected | function | Updates the status of the process. | |
Process:: |
public | function | Waits for the process to terminate. | |
Process:: |
public | function |