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

run() public method

run the process.
public run ( Closure | string | array $callback = null ) : integer
$callback Closure | string | array 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)
    {
        if (null === $this->commandline) {
            $this->commandline = $this->getPhpBinary();
        }
        parent::run($callback);
    }

Usage Example

Beispiel #1
0
 /**
  * Méthode d'execution
  */
 public function run()
 {
     // Initialisation des loggers
     $this->getConfiguration()->initLoggers();
     // Initialisation du process
     $this->createProcess();
     try {
         // Lancement du process
         $this->process->run(function ($type, $buffer) {
             // On affiche le debug à l'écran pour s'assurer qu'aucune erreur
             // bloquante n'est présente et suivre l'exécution des longs process
             if ('err' === $type) {
                 echo 'ERR > ' . $buffer;
             } else {
                 echo 'OUT > ' . $buffer;
             }
         });
         // On récupère la sortie standard en cas de succès (STDOUT)
         if ($this->process->isSuccessful()) {
             $this->message .= $this->process->getOutput();
         } else {
             // On récupère la sortie standard en cas d'erreur (STDERR)
             $this->message .= $this->process->getErrorOutput();
         }
     } catch (\Exception $e) {
         $this->message .= $e->getMessage();
     }
     // Log du process
     $this->report();
     // Envoi des notifications
     $this->notify();
 }
All Usage Examples Of Symfony\Component\Process\PhpProcess::run