mirror of
https://github.com/danog/process.git
synced 2024-12-12 17:17:21 +01:00
19 lines
468 B
PHP
19 lines
468 B
PHP
<?php
|
|
|
|
include dirname(__DIR__) . "/vendor/autoload.php";
|
|
|
|
use Amp\{ Listener, Process\StreamedProcess };
|
|
|
|
AsyncInterop\Loop::execute(\Amp\wrap(function() {
|
|
$process = new StreamedProcess("echo 1; sleep 1; echo 2; sleep 1; echo 3");
|
|
$process->execute();
|
|
|
|
$listener = new Listener($process->getStdOut());
|
|
|
|
while (yield $listener->advance()) {
|
|
echo $listener->getCurrent();
|
|
}
|
|
|
|
echo "Process exited with {$listener->getResult()}.\n";
|
|
}));
|