Symfony\Component\Process\PhpProcess
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>
Synopsis
class PhpProcess
extends Process
{
- // Inherited constants from Process
- 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;
- // members
- private $executableFinder;
- // Inherited members from Process
- public array $exitCodes;
- // methods
- public void __construct()
- public void setPhpBinary()
- public void start()
- // Inherited methods from Process
- public void __construct()
- public void __destruct()
- public void __clone()
- public integer run()
- public void start()
- public Process restart()
- public integer wait()
- public integer|null getPid()
- public Process signal()
- public string getOutput()
- public string getIncrementalOutput()
- public string getErrorOutput()
- public string getIncrementalErrorOutput()
- public integer getExitCode()
- public string getExitCodeText()
- public Boolean isSuccessful()
- public Boolean hasBeenSignaled()
- public integer getTermSignal()
- public Boolean hasBeenStopped()
- public integer getStopSignal()
- public Boolean isRunning()
- public Boolean isStarted()
- public Boolean isTerminated()
- public string getStatus()
- public integer stop()
- public void addOutput()
- public void addErrorOutput()
- public string getCommandLine()
- public self setCommandLine()
- public integer|null getTimeout()
- public self setTimeout()
- public self setTty()
- public Boolean isTty()
- public string getWorkingDirectory()
- public self setWorkingDirectory()
- public array getEnv()
- public self setEnv()
- public string getStdin()
- public self setStdin()
- public array getOptions()
- public self setOptions()
- public Boolean getEnhanceWindowsCompatibility()
- public self setEnhanceWindowsCompatibility()
- public Boolean getEnhanceSigchildCompatibility()
- public self setEnhanceSigchildCompatibility()
- public void checkTimeout()
- protected callback buildCallback()
- protected void updateStatus()
- protected void updateErrorOutput()
- protected void updateOutput()
- protected Boolean isSigchildEnabled()
Hierarchy
Constants
Name | Value |
---|---|
ERR | 'err' |
OUT | 'out' |
STATUS_READY | 'ready' |
STATUS_STARTED | 'started' |
STATUS_TERMINATED | 'terminated' |
STDIN | 0 |
STDOUT | 1 |
STDERR | 2 |
TIMEOUT_PRECISION | 0.2 |
Members
private
- $executableFinder
public
- $exitCodes
—
array
Exit codes translation table.
Methods
public
- __construct() — Constructor.
- setPhpBinary() — Sets the path to the PHP binary to use.
- start() — {@inheritdoc}
Inherited from Symfony\Component\Process\Process
protected
- buildCallback() — Builds up the callback used by wait().
- isSigchildEnabled() — Returns whether PHP has been compiled with the '--enable-sigchild' option or not.
- updateErrorOutput() — Updates the current error output of the process (STDERR).
- updateOutput() — Updates the current output of the process (STDOUT).
- updateStatus() — Updates the status of the process.
public
- __clone()
- addErrorOutput() — Adds a line to the STDERR stream.
- addOutput() — Adds a line to the STDOUT stream.
- checkTimeout() — Performs a check between the timeout definition and the time the process started.
- getCommandLine() — Gets the command line to be executed.
- getEnhanceSigchildCompatibility() — Returns whether sigchild compatibility mode is activated or not.
- getEnhanceWindowsCompatibility() — Gets whether or not Windows compatibility is enabled.
- getEnv() — Gets the environment variables.
- getErrorOutput() — Returns the current error output of the process (STDERR).
- getExitCode() — Returns the exit code returned by the process.
- getExitCodeText() — Returns a string representation for the exit code returned by the process.
- getIncrementalErrorOutput() — Returns the errorOutput incrementally.
- getIncrementalOutput() — Returns the output incrementally.
- getOptions() — Gets the options for proc_open.
- getOutput() — Returns the current output of the process (STDOUT).
- getPid() — Returns the Pid (process identifier), if applicable.
- getStatus() — Gets the process status.
- getStdin() — Gets the contents of STDIN.
- getStopSignal() — Returns the number of the signal that caused the child process to stop its execution.
- getTermSignal() — Returns the number of the signal that caused the child process to terminate its execution.
- getTimeout() — Gets the process timeout.
- getWorkingDirectory() — Gets the working directory.
- hasBeenSignaled() — Returns true if the child process has been terminated by an uncaught signal.
- hasBeenStopped() — Returns true if the child process has been stopped by a signal.
- isRunning() — Checks if the process is currently running.
- isStarted() — Checks if the process has been started with no regard to the current state.
- isSuccessful() — Checks if the process ended successfully.
- isTerminated() — Checks if the process is terminated.
- isTty() — Checks if the TTY mode is enabled.
- restart() — Restarts the process.
- run() — Runs the process.
- setCommandLine() — Sets the command line to be executed.
- setEnhanceSigchildCompatibility() — Activates sigchild compatibility mode.
- setEnhanceWindowsCompatibility() — Sets whether or not Windows compatibility is enabled.
- setEnv() — Sets the environment variables.
- setOptions() — Sets the options for proc_open.
- setStdin() — Sets the contents of STDIN.
- setTimeout() — Sets the process timeout.
- setTty() — Enables or disables the TTY mode.
- setWorkingDirectory() — Sets the current working directory.
- signal() — Sends a posix signal to the process.
- start() — Starts the process and returns after sending the STDIN.
- stop() — Stops the process.
- wait() — Waits for the process to terminate.