You are here

class PhpProcess in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/process/PhpProcess.php \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>

Hierarchy

Expanded class hierarchy of PhpProcess

2 files declare their use of PhpProcess
Client.php in vendor/symfony/browser-kit/Client.php
PhpProcessTest.php in vendor/symfony/process/Tests/PhpProcessTest.php

File

vendor/symfony/process/PhpProcess.php, line 25

Namespace

Symfony\Component\Process
View source
class PhpProcess extends Process {

  /**
   * Constructor.
   *
   * @param string      $script  The PHP script to run (as a string)
   * @param string|null $cwd     The working directory or null to use the working dir of the current PHP process
   * @param array|null  $env     The environment variables or null to use the same environment as the current PHP process
   * @param int         $timeout The timeout in seconds
   * @param array       $options An array of options for proc_open
   */
  public function __construct($script, $cwd = null, array $env = null, $timeout = 60, array $options = array()) {
    $executableFinder = new PhpExecutableFinder();
    if (false === ($php = $executableFinder
      ->find())) {
      $php = null;
    }
    parent::__construct($php, $cwd, $env, $script, $timeout, $options);
  }

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

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

}

Members

Namesort descending Modifiers Type Description Overrides
PhpProcess::setPhpBinary public function Sets the path to the PHP binary to use.
PhpProcess::start public function Starts the process and returns after writing the input to STDIN. Overrides Process::start
PhpProcess::__construct public function Constructor. Overrides Process::__construct
Process::$callback private property
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::$idleTimeout private property
Process::$incrementalErrorOutputOffset private property
Process::$incrementalOutputOffset private property
Process::$input private property
Process::$lastOutputTime private property
Process::$latestSignal private property
Process::$options private property
Process::$outputDisabled private property
Process::$process private property
Process::$processInformation private property
Process::$processPipes private property @var PipesInterface
Process::$pty private property
Process::$sigchild private static property
Process::$starttime private property
Process::$status private property
Process::$stderr private property
Process::$stdout private property
Process::$timeout private property
Process::$tty private property
Process::$useFileHandles 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::captureExitCode private function Captures the exitcode if mentioned in the process information.
Process::checkTimeout public function Performs a check between the timeout definition and the time the process started.
Process::clearErrorOutput public function Clears the process output.
Process::clearOutput public function Clears the process output.
Process::close private function Closes process resource, closes file handles, sets the exitcode.
Process::disableOutput public function Disables fetching output and error output from the underlying process.
Process::doSignal private function Sends a POSIX signal to the process.
Process::enableOutput public function Enables fetching output and error output from the underlying process.
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::getIdleTimeout public function Gets the process idle timeout (max. time since last output).
Process::getIncrementalErrorOutput public function Returns the errorOutput incrementally.
Process::getIncrementalOutput public function Returns the output incrementally.
Process::getInput public function Gets the Process input.
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 Deprecated 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 (max. runtime).
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::isOutputDisabled public function Returns true in case the output is disabled, false otherwise.
Process::isPty public function Returns PTY state.
Process::isPtySupported public static function Returns whether PTY is supported on the current operating system.
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::mustRun public function Runs the process.
Process::OUT constant
Process::readPipes private function Reads pipes, executes callback.
Process::requireProcessIsStarted private function Ensures the process is running or terminated, throws a LogicException if the process has a not started.
Process::requireProcessIsTerminated private function Ensures the process is terminated, throws a LogicException if the process has a status different than `terminated`.
Process::resetProcessData private function Resets data related to the latest run of the process.
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::setIdleTimeout public function Sets the process idle timeout (max. time since last output).
Process::setInput public function Sets the input.
Process::setOptions public function Sets the options for proc_open.
Process::setPty public function Sets PTY mode.
Process::setStdin Deprecated public function Sets the contents of STDIN.
Process::setTimeout public function Sets the process timeout (max. runtime).
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::updateStatus protected function Updates the status of the process, reads pipes.
Process::validateTimeout private function Validates and returns the filtered timeout.
Process::wait public function Waits for the process to terminate.
Process::__clone public function
Process::__destruct public function