class Process
Process is a thin wrapper around proc_* functions to ease start independent PHP processes.
Methods
|
__construct(string $commandline, string $cwd = null, array $env = null, string $stdin = null, 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). |
|
| string |
getErrorOutput()
Returns the error output of the process (STDERR). |
|
| integer |
getExitCode()
Returns the exit code returned by the process. |
|
| Boolean |
isSuccessful()
Checks if the process ended successfully. |
|
| Boolean |
hasBeenSignaled()
Returns true if the child process has been terminated by an uncaught signal. |
|
| integer |
getTermSignal()
Returns the number of the signal that caused the child process to terminate its execution. |
|
| Boolean |
hasBeenStopped()
Returns true if the child process has been stopped by a signal. |
|
| integer |
getStopSignal()
Returns the number of the signal that caused the child process to stop its execution |
|
| addOutput($line) | ||
| addErrorOutput($line) | ||
| getCommandLine() | ||
| setCommandLine($commandline) | ||
| getTimeout() | ||
| setTimeout($timeout) | ||
| getWorkingDirectory() | ||
| setWorkingDirectory($cwd) | ||
| getEnv() | ||
| setEnv(array $env) | ||
| getStdin() | ||
| setStdin($stdin) | ||
| getOptions() | ||
| setOptions(array $options) |
Details
at line 49
public
__construct(string $commandline, string $cwd = null, array $env = null, string $stdin = null, integer $timeout = 60, array $options = array())
Constructor.
at line 89
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.
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.
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.
at line 222
public integer
getExitCode()
Returns the exit code returned by the process.
at line 234
public Boolean
isSuccessful()
Checks if the process ended successfully.
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.
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.
at line 276
public Boolean
hasBeenStopped()
Returns true if the child process has been stopped by a signal.
It always returns false on Windows.
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.