mirror of
https://github.com/danog/process.git
synced 2024-12-12 09:09:44 +01:00
3f3434ba18
Merged Process and StreamedProcess from amphp/parallel that will now depend on this package.
19 lines
466 B
PHP
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";
|
|
}));
|