Class Symfony\Component\Process\PhpProcess

InheritanceSymfony\Component\Process\PhpProcess » Symfony\Component\Process\Process
ImplementsIteratorAggregate

PhpProcess runs a PHP script in an independent process.

$p = new PhpProcess('<?php echo "foo"; ?>'); $p->run(); print $p->getOutput()."\n";

Public Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$exitCodes array Symfony\Component\Process\Process

Public Methods

Hide inherited methods

MethodDescriptionDefined By
__clone() Symfony\Component\Process\Process
__construct() Constructor. Symfony\Component\Process\PhpProcess
__destruct() Symfony\Component\Process\Process
addErrorOutput() Adds a line to the STDERR stream. Symfony\Component\Process\Process
addOutput() Adds a line to the STDOUT stream. Symfony\Component\Process\Process
checkTimeout() Performs a check between the timeout definition and the time the process started. Symfony\Component\Process\Process
clearErrorOutput() Clears the process output. Symfony\Component\Process\Process
clearOutput() Clears the process output. Symfony\Component\Process\Process
disableOutput() Disables fetching output and error output from the underlying process. Symfony\Component\Process\Process
enableOutput() Enables fetching output and error output from the underlying process. Symfony\Component\Process\Process
getCommandLine() Gets the command line to be executed. Symfony\Component\Process\Process
getEnhanceSigchildCompatibility() Returns whether sigchild compatibility mode is activated or not. Symfony\Component\Process\Process
getEnhanceWindowsCompatibility() Gets whether or not Windows compatibility is enabled. Symfony\Component\Process\Process
getEnv() Gets the environment variables. Symfony\Component\Process\Process
getErrorOutput() Returns the current error output of the process (STDERR). Symfony\Component\Process\Process
getExitCode() Returns the exit code returned by the process. Symfony\Component\Process\Process
getExitCodeText() Returns a string representation for the exit code returned by the process. Symfony\Component\Process\Process
getIdleTimeout() Gets the process idle timeout (max. time since last output). Symfony\Component\Process\Process
getIncrementalErrorOutput() Returns the errorOutput incrementally. Symfony\Component\Process\Process
getIncrementalOutput() Returns the output incrementally. Symfony\Component\Process\Process
getInput() Gets the Process input. Symfony\Component\Process\Process
getIterator() Returns an iterator to the output of the process, with the output type as keys (Process::OUT/ERR). Symfony\Component\Process\Process
getOptions() Gets the options for proc_open. Symfony\Component\Process\Process
getOutput() Returns the current output of the process (STDOUT). Symfony\Component\Process\Process
getPid() Returns the Pid (process identifier), if applicable. Symfony\Component\Process\Process
getStatus() Gets the process status. Symfony\Component\Process\Process
getStopSignal() Returns the number of the signal that caused the child process to stop its execution. Symfony\Component\Process\Process
getTermSignal() Returns the number of the signal that caused the child process to terminate its execution. Symfony\Component\Process\Process
getTimeout() Gets the process timeout (max. runtime). Symfony\Component\Process\Process
getWorkingDirectory() Gets the working directory. Symfony\Component\Process\Process
hasBeenSignaled() Returns true if the child process has been terminated by an uncaught signal. Symfony\Component\Process\Process
hasBeenStopped() Returns true if the child process has been stopped by a signal. Symfony\Component\Process\Process
isOutputDisabled() Returns true in case the output is disabled, false otherwise. Symfony\Component\Process\Process
isPty() Returns PTY state. Symfony\Component\Process\Process
isPtySupported() Returns whether PTY is supported on the current operating system. Symfony\Component\Process\Process
isRunning() Checks if the process is currently running. Symfony\Component\Process\Process
isStarted() Checks if the process has been started with no regard to the current state. Symfony\Component\Process\Process
isSuccessful() Checks if the process ended successfully. Symfony\Component\Process\Process
isTerminated() Checks if the process is terminated. Symfony\Component\Process\Process
isTty() Checks if the TTY mode is enabled. Symfony\Component\Process\Process
mustRun() Runs the process. Symfony\Component\Process\Process
restart() Restarts the process. Symfony\Component\Process\Process
run() Runs the process. Symfony\Component\Process\Process
setCommandLine() Sets the command line to be executed. Symfony\Component\Process\Process
setEnhanceSigchildCompatibility() Activates sigchild compatibility mode. Symfony\Component\Process\Process
setEnhanceWindowsCompatibility() Sets whether or not Windows compatibility is enabled. Symfony\Component\Process\Process
setEnv() Sets the environment variables. Symfony\Component\Process\Process
setIdleTimeout() Sets the process idle timeout (max. time since last output). Symfony\Component\Process\Process
setInput() Sets the input. Symfony\Component\Process\Process
setOptions() Sets the options for proc_open. Symfony\Component\Process\Process
setPhpBinary() Sets the path to the PHP binary to use. Symfony\Component\Process\PhpProcess
setPty() Sets PTY mode. Symfony\Component\Process\Process
setTimeout() Sets the process timeout (max. runtime). Symfony\Component\Process\Process
setTty() Enables or disables the TTY mode. Symfony\Component\Process\Process
setWorkingDirectory() Sets the current working directory. Symfony\Component\Process\Process
signal() Sends a POSIX signal to the process. Symfony\Component\Process\Process
start() {@inheritdoc} Symfony\Component\Process\PhpProcess
stop() Stops the process. Symfony\Component\Process\Process
wait() Waits for the process to terminate. Symfony\Component\Process\Process

Protected Methods

Hide inherited methods

MethodDescriptionDefined By
buildCallback() Builds up the callback used by wait(). Symfony\Component\Process\Process
isSigchildEnabled() Returns whether PHP has been compiled with the '--enable-sigchild' option or not. Symfony\Component\Process\Process
updateStatus() Updates the status of the process, reads pipes. Symfony\Component\Process\Process

Method Details

__construct() public method

Constructor.

public void __construct ( $script, $cwd null, array $env null, $timeout 60, array $options = [] )
$script string

The PHP script to run (as a string)

$cwd string|null

The working directory or null to use the working dir of the current PHP process

$env array|null

The environment variables or null to use the same environment as the current PHP process

$timeout int

The timeout in seconds

$options array

An array of options for proc_open

setPhpBinary() public method

Sets the path to the PHP binary to use.

public void setPhpBinary ( $php )
$php
start() public method

{@inheritdoc}

public void start ( callable $callback null )
$callback