Symfony\Component\Process\Process::addErrorOutput PHP Method

addErrorOutput() public method

Adds a line to the STDERR stream.
public addErrorOutput ( string $line )
$line string The line to append
    public function addErrorOutput($line)
    {
        $this->lastOutputTime = microtime(true);
        fseek($this->stderr, 0, SEEK_END);
        fwrite($this->stderr, $line);
        fseek($this->stderr, $this->incrementalErrorOutputOffset);
    }

Usage Example

 public function __construct()
 {
     // parsing cron file
     $process = new Process('crontab -l');
     $process->run();
     $lines = array_filter(explode(PHP_EOL, $process->getOutput()), function ($line) {
         return '' != trim($line);
     });
     foreach ($lines as $lineNumber => $line) {
         // if line is nt a comment, convert it to a cron
         if (strpos($line, '#suspended: ', 0) === 0 || 0 !== strpos($line, '#', 0)) {
             try {
                 $line = Cron::parse($line);
             } catch (\Exception $e) {
                 $process->addErrorOutput('CronManager was unable to parse crontab at line ' . $lineNumber);
             }
         }
         $this->lines['l' . $lineNumber] = $line;
     }
     $this->error = $process->getErrorOutput();
 }
All Usage Examples Of Symfony\Component\Process\Process::addErrorOutput