public function ProcessHelper::run in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/console/Helper/ProcessHelper.php \Symfony\Component\Console\Helper\ProcessHelper::run()
Runs an external process.
Parameters
OutputInterface $output An OutputInterface instance:
string|array|Process $cmd An instance of Process or an array of arguments to escape and run or a command to run:
string|null $error An error message that must be displayed if something went wrong:
callable|null $callback A PHP callback to run whenever there is some: output available on STDOUT or STDERR
int $verbosity The threshold for verbosity:
Return value
Process The process that ran
1 call to ProcessHelper::run()
- ProcessHelper::mustRun in vendor/
symfony/ console/ Helper/ ProcessHelper.php - Runs the process.
File
- vendor/
symfony/ console/ Helper/ ProcessHelper.php, line 39
Class
- ProcessHelper
- The ProcessHelper class provides helpers to run external processes.
Namespace
Symfony\Component\Console\HelperCode
public function run(OutputInterface $output, $cmd, $error = null, $callback = null, $verbosity = OutputInterface::VERBOSITY_VERY_VERBOSE) {
if ($output instanceof ConsoleOutputInterface) {
$output = $output
->getErrorOutput();
}
$formatter = $this
->getHelperSet()
->get('debug_formatter');
if (is_array($cmd)) {
$process = ProcessBuilder::create($cmd)
->getProcess();
}
elseif ($cmd instanceof Process) {
$process = $cmd;
}
else {
$process = new Process($cmd);
}
if ($verbosity <= $output
->getVerbosity()) {
$output
->write($formatter
->start(spl_object_hash($process), $this
->escapeString($process
->getCommandLine())));
}
if ($output
->isDebug()) {
$callback = $this
->wrapCallback($output, $process, $callback);
}
$process
->run($callback);
if ($verbosity <= $output
->getVerbosity()) {
$message = $process
->isSuccessful() ? 'Command ran successfully' : sprintf('%s Command did not run successfully', $process
->getExitCode());
$output
->write($formatter
->stop(spl_object_hash($process), $message, $process
->isSuccessful()));
}
if (!$process
->isSuccessful() && null !== $error) {
$output
->writeln(sprintf('<error>%s</error>', $this
->escapeString($error)));
}
return $process;
}