1
0
mirror of https://github.com/danog/process.git synced 2025-01-08 13:48:37 +01:00
process/example/write-command.php

22 lines
501 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('read ; echo "$REPLY"');
$process->start();
/* send to stdin */
$process->write("abc\n");
$listener = new Listener($process->getStdOut());
while (yield $listener->advance()) {
echo $listener->getCurrent();
}
echo "Process exited with {$listener->getResult()}.\n";
}));