Symfony\Component\Process\Process::getCommandLine PHP Méthode

getCommandLine() public méthode

Gets the command line to be executed.
public getCommandLine ( ) : string
Résultat string The command to execute
    public function getCommandLine()
    {
        return $this->commandline;
    }

Usage Example

 /**
  * @param Process     $process
  * @param bool        $mustRun
  * @param bool        $quiet
  *
  * @return int|string
  * @throws \Exception
  */
 protected function runProcess(Process $process, $mustRun = false, $quiet = true)
 {
     if ($this->output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
         $this->output->writeln("Running command: <info>" . $process->getCommandLine() . "</info>");
     }
     try {
         $process->mustRun($quiet ? null : function ($type, $buffer) {
             $this->output->write(preg_replace('/^/m', '  ', $buffer));
         });
     } catch (ProcessFailedException $e) {
         if (!$mustRun) {
             return $process->getExitCode();
         }
         // The default for ProcessFailedException is to print the entire
         // STDOUT and STDERR. But if $quiet is disabled, then the user will
         // have already seen the command's output.  So we need to re-throw
         // the exception with a much shorter message.
         $message = "The command failed with the exit code: " . $process->getExitCode();
         $message .= "\n\nFull command: " . $process->getCommandLine();
         if ($quiet) {
             $message .= "\n\nError output:\n" . $process->getErrorOutput();
         }
         throw new \Exception($message);
     }
     $output = $process->getOutput();
     return $output ? rtrim($output) : true;
 }
All Usage Examples Of Symfony\Component\Process\Process::getCommandLine