Symfony\Component\Process\Process::getIncrementalErrorOutput PHP Method

getIncrementalErrorOutput() public method

In comparison with the getErrorOutput method which always return the whole error output, this one returns the new error output since the last call.
public getIncrementalErrorOutput ( ) : string
return string The process error output since the last call
    public function getIncrementalErrorOutput()
    {
        $this->readPipesForOutput(__FUNCTION__);
        $latest = stream_get_contents($this->stderr, -1, $this->incrementalErrorOutputOffset);
        $this->incrementalErrorOutputOffset = ftell($this->stderr);
        if (false === $latest) {
            return '';
        }
        return $latest;
    }

Usage Example

 /**
  * Looks into and processes the child's output
  *
  * @param string $childName
  * @return void
  */
 public function processOutput($childName)
 {
     $output = $this->outputBuffer . $this->process->getIncrementalOutput();
     $errorOutput = $this->errorOutputBuffer . $this->process->getIncrementalErrorOutput();
     $outputLines = explode("\n", $output);
     $errorOutputLines = explode("\n", $errorOutput);
     if (count($outputLines) > 0) {
         $lastItem = array_pop($outputLines);
         $this->outputBuffer = $lastItem;
         $this->bufferLength += implode("\n", $outputLines);
         foreach ($outputLines as $line) {
             if (strstr($line, "[[CHILD::BUSY]]")) {
                 $this->parent->verboseOutput('<info>' . $childName . ' BUSY</info>');
                 $this->status = ChildProcessContainer::STATUS_BUSY;
             } elseif (strstr($line, "[[CHILD::READY]]")) {
                 $this->parent->verboseOutput('<info>' . $childName . ' READY</info>');
                 if ($this->status != ChildProcessContainer::STATUS_BUSY_BUT_SLEEPY) {
                     $this->status = ChildProcessContainer::STATUS_READY;
                 } else {
                     $this->status = ChildProcessContainer::STATUS_SLEEPY;
                 }
             } elseif (strlen($line) > 0) {
                 $this->parent->verboseOutput('<info>OUTPUT ' . $childName . ':</info>' . $line);
             }
         }
     }
     if (count($errorOutputLines) > 0) {
         $lastItemError = array_pop($errorOutputLines);
         $this->errorOutputBuffer = $lastItemError;
         $knownErrorOutput = implode("\n", $errorOutputLines);
         $this->bufferLength += strlen($knownErrorOutput);
     }
 }
All Usage Examples Of Symfony\Component\Process\Process::getIncrementalErrorOutput