Class
Process
Starts a child process whose standard streams are used from coroutines without blocking the others.
Class synopsis#
final class Process {
/* Methods */
public static Process::run(
string $command,
array $arguments = [],
?string $cwd = null,
?array $env = null
): ProcessInterface
}Methods#
| Method | Description |
|---|---|
run | Starts $command in the background and returns the object that controls it. |
Examples#
phasync::run(function () {
$process = phasync\Util\Process::run('echo', ['hello']);
echo $process->read(); // hello
while ($process->isRunning()) {
phasync::sleep(0.01);
}
var_dump($process->getExitCode()); // int(0)
});See also#
ProcessInterfaceA child process started withProcess::run(), with its standard streams usable from coroutines.ProcessRunnerThe implementation behindProcess::run(): starts a child process and controls it.