Symfony\Component\Process\Process::mustRun PHP Method

mustRun() public method

This is identical to run() except that an exception is thrown if the process exits with a non-zero exit code.
public mustRun ( callable $callback = null ) : self
$callback callable
return self
    public function mustRun(callable $callback = null)
    {
        if (!$this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
            throw new RuntimeException('This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method.');
        }
        if (0 !== $this->run($callback)) {
            throw new ProcessFailedException($this);
        }
        return $this;
    }

Usage Example

 /**
  * Runs a process and returns the output.
  *
  * @param Process $process
  * @return string
  */
 public function run(Process $process, $returnOutput = true)
 {
     $process->mustRun();
     if ($returnOutput) {
         return $this->getProcessOutput($process);
     }
 }
All Usage Examples Of Symfony\Component\Process\Process::mustRun