public function Process::start in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/process/Process.php \Symfony\Component\Process\Process::start()
Starts the process and returns after writing the input to STDIN.
This method blocks until all STDIN data is sent to the process then it returns while the process runs in the background.
The termination of the process can be awaited with wait().
The callback receives the type of output (out or err) and some bytes from the output in real-time while writing the standard input to the process. It allows to have feedback from the independent process during execution. If there is no callback passed, the wait() method can be called with true as a second parameter then the callback will get all data occurred in (and since) the start call.
Parameters
callable|null $callback A PHP callback to run whenever there is some: output available on STDOUT or STDERR
Throws
RuntimeException When process can't be launched
RuntimeException When process is already running
LogicException In case a callback is provided and output has been disabled
2 calls to Process::start()
- PhpProcess::start in vendor/
symfony/ process/ PhpProcess.php - Starts the process and returns after writing the input to STDIN.
- Process::run in vendor/
symfony/ process/ Process.php - Runs the process.
1 method overrides Process::start()
- PhpProcess::start in vendor/
symfony/ process/ PhpProcess.php - Starts the process and returns after writing the input to STDIN.
File
- vendor/
symfony/ process/ Process.php, line 255
Class
- Process
- Process is a thin wrapper around proc_* functions to easily start independent PHP processes.
Namespace
Symfony\Component\ProcessCode
public function start($callback = null) {
if ($this
->isRunning()) {
throw new RuntimeException('Process is already running');
}
if ($this->outputDisabled && null !== $callback) {
throw new LogicException('Output has been disabled, enable it to allow the use of a callback.');
}
$this
->resetProcessData();
$this->starttime = $this->lastOutputTime = microtime(true);
$this->callback = $this
->buildCallback($callback);
$descriptors = $this
->getDescriptors();
$commandline = $this->commandline;
if ('\\' === DIRECTORY_SEPARATOR && $this->enhanceWindowsCompatibility) {
$commandline = 'cmd /V:ON /E:ON /D /C "(' . $commandline . ')';
foreach ($this->processPipes
->getFiles() as $offset => $filename) {
$commandline .= ' ' . $offset . '>' . ProcessUtils::escapeArgument($filename);
}
$commandline .= '"';
if (!isset($this->options['bypass_shell'])) {
$this->options['bypass_shell'] = true;
}
}
$this->process = proc_open($commandline, $descriptors, $this->processPipes->pipes, $this->cwd, $this->env, $this->options);
if (!is_resource($this->process)) {
throw new RuntimeException('Unable to launch a new process.');
}
$this->status = self::STATUS_STARTED;
if ($this->tty) {
return;
}
$this
->updateStatus(false);
$this
->checkTimeout();
}