Symfony\Component\Process\Process::enableOutput PHP Method

enableOutput() public method

Enables fetching output and error output from the underlying process.
public enableOutput ( ) : Process
return Process
    public function enableOutput()
    {
        if ($this->isRunning()) {
            throw new RuntimeException('Enabling output while the process is running is not possible.');
        }
        $this->outputDisabled = false;
        return $this;
    }

Usage Example

Example #1
0
 public static function shell($commands, array $opts = [])
 {
     //$cwd = null, array $env = null, $input = null, $timeout = 60, array $options = array()
     if (is_array($commands)) {
         $procs = [];
         foreach ($commands as $command) {
             $procs[] = static::shell($command, $opts);
         }
         return $procs;
     }
     $process = new Process($commands);
     $options = array_replace(['type' => 'sync', 'cwd' => null, 'env' => null, 'timeout' => 60, 'callback' => null, 'output' => true], $opts);
     $options['cwd'] !== null && $process->setWorkingDirectory($options['cwd']);
     $options['env'] !== null && $process->setEnv($options['env']);
     is_int($options['timeout']) && $process->setTimeout($options['timeout']);
     if ($options['output'] === true) {
         $process->enableOutput();
     } else {
         $process->disableOutput();
     }
     $type = $options['type'];
     if ($type === 'sync') {
         $process->run($options['callback']);
     } elseif ($type === 'async') {
         $process->start();
     }
     return $process;
 }
All Usage Examples Of Symfony\Component\Process\Process::enableOutput