class PhpProcess extends Process
PhpProcess runs a PHP script in an independent process.
$p = new PhpProcess('<?php echo "foo"; ?>');
$p->run();
print $p->getOutput()."\n";
Methods
|
__construct(string $script, string $cwd = null, array $env = array(), integer $timeout = 60, array $options = array())
Constructor. |
||
| integer |
run(Closure|string|array $callback = null)
Runs the process. |
|
| string |
getOutput()
Returns the output of the process (STDOUT). |
from Process |
| string |
getErrorOutput()
Returns the error output of the process (STDERR). |
from Process |
| integer |
getExitCode()
Returns the exit code returned by the process. |
from Process |
| Boolean |
isSuccessful()
Checks if the process ended successfully. |
from Process |
| Boolean |
hasBeenSignaled()
Returns true if the child process has been terminated by an uncaught signal. |
from Process |
| integer |
getTermSignal()
Returns the number of the signal that caused the child process to terminate its execution. |
from Process |
| Boolean |
hasBeenStopped()
Returns true if the child process has been stopped by a signal. |
from Process |
| integer |
getStopSignal()
Returns the number of the signal that caused the child process to stop its execution |
from Process |
| addOutput($line) | from Process | |
| addErrorOutput($line) | from Process | |
| getCommandLine() | from Process | |
| setCommandLine($commandline) | from Process | |
| getTimeout() | from Process | |
| setTimeout($timeout) | from Process | |
| getWorkingDirectory() | from Process | |
| setWorkingDirectory($cwd) | from Process | |
| getEnv() | from Process | |
| setEnv(array $env) | from Process | |
| getStdin() | from Process | |
| setStdin($stdin) | from Process | |
| getOptions() | from Process | |
| setOptions(array $options) | from Process | |
|
setPhpBinary($php)
Sets the path to the PHP binary to use. |
Details
at line 40
public
__construct(string $script, string $cwd = null, array $env = array(), integer $timeout = 60, array $options = array())
Constructor.
at line 67
public integer
run(Closure|string|array $callback = null)
Runs the process.
The callback receives the type of output (out or err) and
some bytes from the output in real-time. It allows to have feedback
from the independent process during execution.
The STDOUT and STDERR are also available after the process is finished
via the getOutput() and getErrorOutput() methods.
in Process at line 195
public string
getOutput()
Returns the output of the process (STDOUT).
This only returns the output if you have not supplied a callback
to the run() method.
in Process at line 210
public string
getErrorOutput()
Returns the error output of the process (STDERR).
This only returns the error output if you have not supplied a callback
to the run() method.
in Process at line 222
public integer
getExitCode()
Returns the exit code returned by the process.
in Process at line 234
public Boolean
isSuccessful()
Checks if the process ended successfully.
in Process at line 248
public Boolean
hasBeenSignaled()
Returns true if the child process has been terminated by an uncaught signal.
It always returns false on Windows.
in Process at line 262
public integer
getTermSignal()
Returns the number of the signal that caused the child process to terminate its execution.
It is only meaningful if hasBeenSignaled() returns true.
in Process at line 276
public Boolean
hasBeenStopped()
Returns true if the child process has been stopped by a signal.
It always returns false on Windows.
in Process at line 290
public integer
getStopSignal()
Returns the number of the signal that caused the child process to stop its execution
It is only meaningful if hasBeenStopped() returns true.
in Process at line 295
public
addOutput($line)
in Process at line 300
public
addErrorOutput($line)
in Process at line 305
public
getCommandLine()
in Process at line 310
public
setCommandLine($commandline)
in Process at line 315
public
getTimeout()
in Process at line 320
public
setTimeout($timeout)
in Process at line 325
public
getWorkingDirectory()
in Process at line 330
public
setWorkingDirectory($cwd)
in Process at line 335
public
getEnv()
in Process at line 340
public
setEnv(array $env)
in Process at line 345
public
getStdin()
in Process at line 350
public
setStdin($stdin)
in Process at line 355
public
getOptions()
in Process at line 360
public
setOptions(array $options)
at line 52
public
setPhpBinary($php)
Sets the path to the PHP binary to use.