1
0
mirror of https://github.com/danog/process.git synced 2024-12-12 09:09:44 +01:00
process/example/watch-live.php
Aaron Piotrowski 3f3434ba18 Refactor for Amp v2
Merged Process and StreamedProcess from amphp/parallel that will now depend on this package.
2017-01-11 12:25:52 -06:00

19 lines
466 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->start();
$listener = new Listener($process->getStdOut());
while (yield $listener->advance()) {
echo $listener->getCurrent();
}
echo "Process exited with {$listener->getResult()}.\n";
}));