ILIAS
release_5-2 Revision v5.2.25-18-g3f80b828510
|
PhpProcess runs a PHP script in an independent process. More...
Public Member Functions | ||||||||||
__construct ($script, $cwd=null, array $env=null, $timeout=60, array $options=array()) | ||||||||||
Constructor. More... | ||||||||||
setPhpBinary ($php) | ||||||||||
Sets the path to the PHP binary to use. More... | ||||||||||
start (callable $callback=null) | ||||||||||
{Starts the process and returns after writing the input to STDIN.This method blocks until all STDIN data is sent to the process then it returns while the process runs in the background.The termination of the process can be awaited with wait().The callback receives the type of output (out or err) and some bytes from the output in real-time while writing the standard input to the process. It allows to have feedback from the independent process during execution.
| ||||||||||
![]() | ||||||||||
__construct ($commandline, $cwd=null, array $env=null, $input=null, $timeout=60, array $options=array()) | ||||||||||
Constructor. More... | ||||||||||
__destruct () | ||||||||||
__clone () | ||||||||||
run ($callback=null) | ||||||||||
Runs the process. More... | ||||||||||
mustRun (callable $callback=null) | ||||||||||
Runs the process. More... | ||||||||||
start (callable $callback=null) | ||||||||||
Starts the process and returns after writing the input to STDIN. More... | ||||||||||
restart (callable $callback=null) | ||||||||||
Restarts the process. More... | ||||||||||
wait (callable $callback=null) | ||||||||||
Waits for the process to terminate. More... | ||||||||||
getPid () | ||||||||||
Returns the Pid (process identifier), if applicable. More... | ||||||||||
signal ($signal) | ||||||||||
Sends a POSIX signal to the process. More... | ||||||||||
disableOutput () | ||||||||||
Disables fetching output and error output from the underlying process. More... | ||||||||||
enableOutput () | ||||||||||
Enables fetching output and error output from the underlying process. More... | ||||||||||
isOutputDisabled () | ||||||||||
Returns true in case the output is disabled, false otherwise. More... | ||||||||||
getOutput () | ||||||||||
Returns the current output of the process (STDOUT). More... | ||||||||||
getIncrementalOutput () | ||||||||||
Returns the output incrementally. More... | ||||||||||
getIterator ($flags=0) | ||||||||||
Returns an iterator to the output of the process, with the output type as keys (Process::OUT/ERR). More... | ||||||||||
clearOutput () | ||||||||||
Clears the process output. More... | ||||||||||
getErrorOutput () | ||||||||||
Returns the current error output of the process (STDERR). More... | ||||||||||
getIncrementalErrorOutput () | ||||||||||
Returns the errorOutput incrementally. More... | ||||||||||
clearErrorOutput () | ||||||||||
Clears the process output. More... | ||||||||||
getExitCode () | ||||||||||
Returns the exit code returned by the process. More... | ||||||||||
getExitCodeText () | ||||||||||
Returns a string representation for the exit code returned by the process. More... | ||||||||||
isSuccessful () | ||||||||||
Checks if the process ended successfully. More... | ||||||||||
hasBeenSignaled () | ||||||||||
Returns true if the child process has been terminated by an uncaught signal. More... | ||||||||||
getTermSignal () | ||||||||||
Returns the number of the signal that caused the child process to terminate its execution. More... | ||||||||||
hasBeenStopped () | ||||||||||
Returns true if the child process has been stopped by a signal. More... | ||||||||||
getStopSignal () | ||||||||||
Returns the number of the signal that caused the child process to stop its execution. More... | ||||||||||
isRunning () | ||||||||||
Checks if the process is currently running. More... | ||||||||||
isStarted () | ||||||||||
Checks if the process has been started with no regard to the current state. More... | ||||||||||
isTerminated () | ||||||||||
Checks if the process is terminated. More... | ||||||||||
getStatus () | ||||||||||
Gets the process status. More... | ||||||||||
stop ($timeout=10, $signal=null) | ||||||||||
Stops the process. More... | ||||||||||
addOutput ($line) | ||||||||||
Adds a line to the STDOUT stream. More... | ||||||||||
addErrorOutput ($line) | ||||||||||
Adds a line to the STDERR stream. More... | ||||||||||
getCommandLine () | ||||||||||
Gets the command line to be executed. More... | ||||||||||
setCommandLine ($commandline) | ||||||||||
Sets the command line to be executed. More... | ||||||||||
getTimeout () | ||||||||||
Gets the process timeout (max. More... | ||||||||||
getIdleTimeout () | ||||||||||
Gets the process idle timeout (max. More... | ||||||||||
setTimeout ($timeout) | ||||||||||
Sets the process timeout (max. More... | ||||||||||
setIdleTimeout ($timeout) | ||||||||||
Sets the process idle timeout (max. More... | ||||||||||
setTty ($tty) | ||||||||||
Enables or disables the TTY mode. More... | ||||||||||
isTty () | ||||||||||
Checks if the TTY mode is enabled. More... | ||||||||||
setPty ($bool) | ||||||||||
Sets PTY mode. More... | ||||||||||
isPty () | ||||||||||
Returns PTY state. More... | ||||||||||
getWorkingDirectory () | ||||||||||
Gets the working directory. More... | ||||||||||
setWorkingDirectory ($cwd) | ||||||||||
Sets the current working directory. More... | ||||||||||
getEnv () | ||||||||||
Gets the environment variables. More... | ||||||||||
setEnv (array $env) | ||||||||||
Sets the environment variables. More... | ||||||||||
getInput () | ||||||||||
Gets the Process input. More... | ||||||||||
setInput ($input) | ||||||||||
Sets the input. More... | ||||||||||
getOptions () | ||||||||||
Gets the options for proc_open. More... | ||||||||||
setOptions (array $options) | ||||||||||
Sets the options for proc_open. More... | ||||||||||
getEnhanceWindowsCompatibility () | ||||||||||
Gets whether or not Windows compatibility is enabled. More... | ||||||||||
setEnhanceWindowsCompatibility ($enhance) | ||||||||||
Sets whether or not Windows compatibility is enabled. More... | ||||||||||
getEnhanceSigchildCompatibility () | ||||||||||
Returns whether sigchild compatibility mode is activated or not. More... | ||||||||||
setEnhanceSigchildCompatibility ($enhance) | ||||||||||
Activates sigchild compatibility mode. More... | ||||||||||
checkTimeout () | ||||||||||
Performs a check between the timeout definition and the time the process started. More... | ||||||||||
Additional Inherited Members | |
![]() | |
static | isPtySupported () |
Returns whether PTY is supported on the current operating system. More... | |
![]() | |
const | ERR = 'err' |
const | OUT = 'out' |
const | STATUS_READY = 'ready' |
const | STATUS_STARTED = 'started' |
const | STATUS_TERMINATED = 'terminated' |
const | STDIN = 0 |
const | STDOUT = 1 |
const | STDERR = 2 |
const | TIMEOUT_PRECISION = 0.2 |
const | ITER_NON_BLOCKING = 1 |
const | ITER_KEEP_OUTPUT = 2 |
const | ITER_SKIP_OUT = 4 |
const | ITER_SKIP_ERR = 8 |
![]() | |
static | $exitCodes |
![]() | |
buildCallback (callable $callback=null) | |
Builds up the callback used by wait(). More... | |
updateStatus ($blocking) | |
Updates the status of the process, reads pipes. More... | |
isSigchildEnabled () | |
Returns whether PHP has been compiled with the '–enable-sigchild' option or not. More... | |
PhpProcess runs a PHP script in an independent process.
$p = new PhpProcess('<?php echo "foo"; ?>'); $p->run(); print $p->getOutput()."\n";
Definition at line 25 of file PhpProcess.php.
Symfony\Component\Process\PhpProcess::__construct | ( | $script, | |
$cwd = null , |
|||
array | $env = null , |
||
$timeout = 60 , |
|||
array | $options = array() |
||
) |
Constructor.
string | $script | The PHP script to run (as a string) |
string | null | $cwd | The working directory or null to use the working dir of the current PHP process |
array | null | $env | The environment variables or null to use the same environment as the current PHP process |
int | $timeout | The timeout in seconds |
array | $options | An array of options for proc_open |
Definition at line 36 of file PhpProcess.php.
References Symfony\Component\Process\Process\$cwd, Symfony\Component\Process\Process\$env, $file, Symfony\Component\Process\Process\$options, $php, and Symfony\Component\Process\Process\$timeout.
Symfony\Component\Process\PhpProcess::setPhpBinary | ( | $php | ) |
Sets the path to the PHP binary to use.
Definition at line 62 of file PhpProcess.php.
References $php, and Symfony\Component\Process\Process\setCommandLine().
Symfony\Component\Process\PhpProcess::start | ( | callable | $callback = null | ) |
{Starts the process and returns after writing the input to STDIN.This method blocks until all STDIN data is sent to the process then it returns while the process runs in the background.The termination of the process can be awaited with wait().The callback receives the type of output (out or err) and some bytes from the output in real-time while writing the standard input to the process. It allows to have feedback from the independent process during execution.
callable | null | $callback | A PHP callback to run whenever there is some output available on STDOUT or STDERR |
RuntimeException | When process can't be launched |
RuntimeException | When process is already running |
LogicException | In case a callback is provided and output has been disabled |
Reimplemented from Symfony\Component\Process\Process.
Definition at line 70 of file PhpProcess.php.
References Symfony\Component\Process\Process\$callback, and Symfony\Component\Process\Process\getCommandLine().
Referenced by Symfony\Component\Process\Tests\PhpProcessTest\testNonBlockingWorks().