1
0
mirror of https://github.com/danog/process.git synced 2024-12-03 10:07:46 +01:00
process/examples/basic-command.php
2018-10-14 23:16:09 -05:00

20 lines
510 B
PHP

<?php
include \dirname(__DIR__) . "/vendor/autoload.php";
use Amp\ByteStream\Message;
use Amp\Process\Process;
Amp\Loop::run(function () {
// "echo" is a shell internal command on Windows and doesn't work.
$command = DIRECTORY_SEPARATOR === "\\" ? "cmd /c echo Hello World!" : "echo 'Hello, world!'";
$process = new Process($command);
$process->start();
echo yield new Message($process->getStdout());
$code = yield $process->join();
echo "Process exited with {$code}.\n";
});