Symfony\Component\Process\Process::run PHP Method

run() public method

The callback receives the type of output (out or err) and some bytes from the output in real-time. It allows to have feedback from the independent process during execution. The STDOUT and STDERR are also available after the process is finished via the getOutput() and getErrorOutput() methods.
public run ( callable | null $callback = null ) : integer
$callback callable | null A PHP callback to run whenever there is some output available on STDOUT or STDERR
return integer The exit status code
    public function run($callback = null)
    {
        $this->start($callback);
        return $this->wait();
    }

Usage Example

Example #1
0
 /**
  * @return string
  */
 public function compile()
 {
     $this->stopwatch->start('webpack.total');
     $this->stopwatch->start('webpack.prepare');
     // Recompile twig templates where its needed.
     $this->addSplitPoints();
     $this->addResolveConfig();
     // Write the webpack configuration file.
     file_put_contents($this->cache_dir . DIRECTORY_SEPARATOR . 'webpack.config.js', $this->generator->getConfiguration());
     $this->profiler->set('compiler.performance.prepare', $this->stopwatch->stop('webpack.prepare')->getDuration());
     $this->stopwatch->start('webpack.compiler');
     $this->process->run();
     $output = $this->process->getOutput() . $this->process->getErrorOutput();
     $this->profiler->set('compiler.executed', true);
     $this->profiler->set('compiler.successful', strpos($output, 'Error:') === false);
     $this->profiler->set('compiler.last_output', $output);
     if ($this->profiler->get('compiler.successful')) {
         $this->tracker->rebuild();
     }
     // Finally, write some logging for later use.
     file_put_contents($this->cache_dir . DIRECTORY_SEPARATOR . 'webpack.compiler.log', $output);
     $this->profiler->set('compiler.performance.compiler', $this->stopwatch->stop('webpack.compiler')->getDuration());
     $this->profiler->set('compiler.performance.total', $this->stopwatch->stop('webpack.total')->getDuration());
     return $output;
 }
All Usage Examples Of Symfony\Component\Process\Process::run