ILIAS  release_5-2 Revision v5.2.25-18-g3f80b82851
Symfony\Component\Process\PhpProcess Class Reference

PhpProcess runs a PHP script in an independent process. More...

+ Inheritance diagram for Symfony\Component\Process\PhpProcess:
+ Collaboration diagram for Symfony\Component\Process\PhpProcess:

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)
 {} More...
 
- Public Member Functions inherited from Symfony\Component\Process\Process
 __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 Public Member Functions inherited from Symfony\Component\Process\Process
static isPtySupported ()
 Returns whether PTY is supported on the current operating system. More...
 
- Data Fields inherited from Symfony\Component\Process\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
 
const ITER_NON_BLOCKING = 1
 
const ITER_KEEP_OUTPUT = 2
 
const ITER_SKIP_OUT = 4
 
const ITER_SKIP_ERR = 8
 
- Static Public Attributes inherited from Symfony\Component\Process\Process
static $exitCodes
 
- Protected Member Functions inherited from Symfony\Component\Process\Process
 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...
 

Detailed Description

PhpProcess runs a PHP script in an independent process.

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

Author
Fabien Potencier fabie.nosp@m.n@sy.nosp@m.mfony.nosp@m..com

Definition at line 25 of file PhpProcess.php.

Constructor & Destructor Documentation

◆ __construct()

Symfony\Component\Process\PhpProcess::__construct (   $script,
  $cwd = null,
array  $env = null,
  $timeout = 60,
array  $options = array() 
)

Constructor.

Parameters
string$scriptThe PHP script to run (as a string)
string | null$cwdThe working directory or null to use the working dir of the current PHP process
array | null$envThe environment variables or null to use the same environment as the current PHP process
int$timeoutThe timeout in seconds
array$optionsAn 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.

37  {
38  $executableFinder = new PhpExecutableFinder();
39  if (false === $php = $executableFinder->find()) {
40  $php = null;
41  }
42  if ('phpdbg' === PHP_SAPI) {
43  $file = tempnam(sys_get_temp_dir(), 'dbg');
44  file_put_contents($file, $script);
45  register_shutdown_function('unlink', $file);
46  $php .= ' '.ProcessUtils::escapeArgument($file);
47  $script = null;
48  }
49  if ('\\' !== DIRECTORY_SEPARATOR && null !== $php) {
50  // exec is mandatory to deal with sending a signal to the process
51  // see https://github.com/symfony/symfony/issues/5030 about prepending
52  // command with exec
53  $php = 'exec '.$php;
54  }
55 
56  parent::__construct($php, $cwd, $env, $script, $timeout, $options);
57  }
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
$php
Definition: flush.php:22

Member Function Documentation

◆ setPhpBinary()

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().

63  {
64  $this->setCommandLine($php);
65  }
setCommandLine($commandline)
Sets the command line to be executed.
Definition: Process.php:897
$php
Definition: flush.php:22
+ Here is the call graph for this function:

◆ start()

Symfony\Component\Process\PhpProcess::start ( callable  $callback = null)

{}

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().

71  {
72  if (null === $this->getCommandLine()) {
73  throw new RuntimeException('Unable to find the PHP executable.');
74  }
75 
76  parent::start($callback);
77  }
getCommandLine()
Gets the command line to be executed.
Definition: Process.php:885
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

The documentation for this class was generated from the following file: