1
0
mirror of https://github.com/danog/process.git synced 2024-12-11 16:49:40 +01:00
process/example/watch-live.php

19 lines
468 B
PHP
Raw Normal View History

<?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");
2017-01-11 21:35:07 +01:00
$process->execute();
$listener = new Listener($process->getStdOut());
while (yield $listener->advance()) {
echo $listener->getCurrent();
}
echo "Process exited with {$listener->getResult()}.\n";
}));