class 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>

@api

Hierarchy

Expanded class hierarchy of PhpProcess

1 file declares its use of PhpProcess
PhpProcessTest.php in drupal/core/vendor/symfony/process/Symfony/Component/Process/Tests/PhpProcessTest.php

File

drupal/core/vendor/symfony/process/Symfony/Component/Process/PhpProcess.php, line 27

Namespace

Symfony\Component\Process
View source
class PhpProcess extends Process {
  private $executableFinder;

  /**
   * Constructor.
   *
   * @param string  $script  The PHP script to run (as a string)
   * @param string  $cwd     The working directory
   * @param array   $env     The environment variables
   * @param integer $timeout The timeout in seconds
   * @param array   $options An array of options for proc_open
   *
   * @api
   */
  public function __construct($script, $cwd = null, array $env = array(), $timeout = 60, array $options = array()) {
    parent::__construct(null, $cwd, $env, $script, $timeout, $options);
    $this->executableFinder = new PhpExecutableFinder();
  }

  /**
   * Sets the path to the PHP binary to use.
   *
   * @api
   */
  public function setPhpBinary($php) {
    $this
      ->setCommandLine($php);
  }

  /**
   * {@inheritdoc}
   */
  public function start($callback = null) {
    if (null === $this
      ->getCommandLine()) {
      if (false === ($php = $this->executableFinder
        ->find())) {
        throw new RuntimeException('Unable to find the PHP executable.');
      }
      $this
        ->setCommandLine($php);
    }
    parent::start($callback);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
PhpProcess::$executableFinder private property
PhpProcess::setPhpBinary public function Sets the path to the PHP binary to use.
PhpProcess::start public function Starts the process and returns after sending the STDIN. Overrides Process::start
PhpProcess::__construct public function Constructor. Overrides Process::__construct
Process::$commandline private property
Process::$cwd private property
Process::$enhanceSigchildCompatibility private property
Process::$enhanceWindowsCompatibility private property
Process::$env private property
Process::$exitcode private property
Process::$exitCodes public static property Exit codes translation table.
Process::$fallbackExitcode private property
Process::$fileHandles private property
Process::$incrementalErrorOutputOffset private property
Process::$incrementalOutputOffset private property
Process::$options private property
Process::$pipes private property
Process::$process private property
Process::$processInformation private property
Process::$readBytes private property
Process::$sigchild private static property
Process::$starttime private property
Process::$status private property
Process::$stderr private property
Process::$stdin private property
Process::$stdout private property
Process::$timeout private property
Process::$tty private property
Process::addErrorOutput public function Adds a line to the STDERR stream.
Process::addOutput public function Adds a line to the STDOUT stream.
Process::buildCallback protected function Builds up the callback used by wait().
Process::checkTimeout public function Performs a check between the timeout definition and the time the process started.
Process::ERR constant
Process::getCommandLine public function Gets the command line to be executed.
Process::getDescriptors private function Creates the descriptors needed by the proc_open.
Process::getEnhanceSigchildCompatibility public function Returns whether sigchild compatibility mode is activated or not.
Process::getEnhanceWindowsCompatibility public function Gets whether or not Windows compatibility is enabled.
Process::getEnv public function Gets the environment variables.
Process::getErrorOutput public function Returns the current error output of the process (STDERR).
Process::getExitCode public function Returns the exit code returned by the process.
Process::getExitCodeText public function Returns a string representation for the exit code returned by the process.
Process::getIncrementalErrorOutput public function Returns the errorOutput incrementally.
Process::getIncrementalOutput public function Returns the output incrementally.
Process::getOptions public function Gets the options for proc_open.
Process::getOutput public function Returns the current output of the process (STDOUT).
Process::getPid public function Returns the Pid (process identifier), if applicable.
Process::getStatus public function Gets the process status.
Process::getStdin public function Gets the contents of STDIN.
Process::getStopSignal public function Returns the number of the signal that caused the child process to stop its execution.
Process::getTermSignal public function Returns the number of the signal that caused the child process to terminate its execution.
Process::getTimeout public function Gets the process timeout.
Process::getWorkingDirectory public function Gets the working directory.
Process::hasBeenSignaled public function Returns true if the child process has been terminated by an uncaught signal.
Process::hasBeenStopped public function Returns true if the child process has been stopped by a signal.
Process::isRunning public function Checks if the process is currently running.
Process::isSigchildEnabled protected function Returns whether PHP has been compiled with the '--enable-sigchild' option or not. 1
Process::isStarted public function Checks if the process has been started with no regard to the current state.
Process::isSuccessful public function Checks if the process ended successfully.
Process::isTerminated public function Checks if the process is terminated.
Process::isTty public function Checks if the TTY mode is enabled.
Process::OUT constant
Process::processFileHandles private function Handles the windows file handles fallbacks.
Process::restart public function Restarts the process.
Process::run public function Runs the process.
Process::setCommandLine public function Sets the command line to be executed.
Process::setEnhanceSigchildCompatibility public function Activates sigchild compatibility mode.
Process::setEnhanceWindowsCompatibility public function Sets whether or not Windows compatibility is enabled.
Process::setEnv public function Sets the environment variables.
Process::setOptions public function Sets the options for proc_open.
Process::setStdin public function Sets the contents of STDIN.
Process::setTimeout public function Sets the process timeout.
Process::setTty public function Enables or disables the TTY mode.
Process::setWorkingDirectory public function Sets the current working directory.
Process::signal public function Sends a posix signal to the process.
Process::STATUS_READY constant
Process::STATUS_STARTED constant
Process::STATUS_TERMINATED constant
Process::STDERR constant
Process::STDIN constant
Process::STDOUT constant
Process::stop public function Stops the process.
Process::TIMEOUT_PRECISION constant
Process::updateErrorOutput protected function Updates the current error output of the process (STDERR).
Process::updateOutput protected function Updates the current output of the process (STDOUT).
Process::updateStatus protected function Updates the status of the process.
Process::wait public function Waits for the process to terminate.
Process::__clone public function
Process::__destruct public function