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);
}
/**
* {@inheritdoc}
*/
public function start($callback = null) {
if (null === $this
->getCommandLine()) {
if (false === ($php = $this->executableFinder
->find())) {
throw new RuntimeException('Unable to find the PHP executable.');
}
$this
->setCommandLine($php);
}
parent::start($callback);
}
}
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PhpProcess:: |
private | property | ||
PhpProcess:: |
public | function | Sets the path to the PHP binary to use. | |
PhpProcess:: |
public | function |
Starts the process and returns after sending the STDIN. Overrides Process:: |
|
PhpProcess:: |
public | function |
Constructor. Overrides Process:: |
|
Process:: |
private | property | ||
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 static | 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 | Adds a line to the STDERR stream. | |
Process:: |
public | function | Adds a line to the STDOUT stream. | |
Process:: |
protected | function | Builds up the callback used by wait(). | |
Process:: |
public | function | Performs a check between the timeout definition and the time the process started. | |
Process:: |
constant | |||
Process:: |
public | function | Gets the command line to be executed. | |
Process:: |
private | function | Creates the descriptors needed by the proc_open. | |
Process:: |
public | function | Returns whether sigchild compatibility mode is activated or not. | |
Process:: |
public | function | Gets whether or not Windows compatibility is enabled. | |
Process:: |
public | function | Gets the environment variables. | |
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 | Returns the errorOutput incrementally. | |
Process:: |
public | function | Returns the output incrementally. | |
Process:: |
public | function | Gets the options for proc_open. | |
Process:: |
public | function | Returns the current output of the process (STDOUT). | |
Process:: |
public | function | Returns the Pid (process identifier), if applicable. | |
Process:: |
public | function | Gets the process status. | |
Process:: |
public | function | Gets the contents of STDIN. | |
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 | Gets the process timeout. | |
Process:: |
public | function | Gets the working directory. | |
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:: |
protected | function | Returns whether PHP has been compiled with the '--enable-sigchild' option or not. | 1 |
Process:: |
public | function | Checks if the process has been started with no regard to the current state. | |
Process:: |
public | function | Checks if the process ended successfully. | |
Process:: |
public | function | Checks if the process is terminated. | |
Process:: |
public | function | Checks if the TTY mode is enabled. | |
Process:: |
constant | |||
Process:: |
private | function | Handles the windows file handles fallbacks. | |
Process:: |
public | function | Restarts the process. | |
Process:: |
public | function | Runs the process. | |
Process:: |
public | function | Sets the command line to be executed. | |
Process:: |
public | function | Activates sigchild compatibility mode. | |
Process:: |
public | function | Sets whether or not Windows compatibility is enabled. | |
Process:: |
public | function | Sets the environment variables. | |
Process:: |
public | function | Sets the options for proc_open. | |
Process:: |
public | function | Sets the contents of STDIN. | |
Process:: |
public | function | Sets the process timeout. | |
Process:: |
public | function | Enables or disables the TTY mode. | |
Process:: |
public | function | Sets the current working directory. | |
Process:: |
public | function | Sends a posix signal to the process. | |
Process:: |
constant | |||
Process:: |
constant | |||
Process:: |
constant | |||
Process:: |
constant | |||
Process:: |
constant | |||
Process:: |
constant | |||
Process:: |
public | function | Stops the process. | |
Process:: |
constant | |||
Process:: |
protected | function | Updates the current error output of the process (STDERR). | |
Process:: |
protected | function | Updates the current output of the process (STDOUT). | |
Process:: |
protected | function | Updates the status of the process. | |
Process:: |
public | function | Waits for the process to terminate. | |
Process:: |
public | function | ||
Process:: |
public | function |