1
0
mirror of https://github.com/danog/process.git synced 2024-11-26 20:24:43 +01:00
process/examples/basic-command.php
Aaron Piotrowski 91dc2ec100
Update examples
2018-10-15 09:55:15 -05:00

20 lines
514 B
PHP

<?php
include \dirname(__DIR__) . "/vendor/autoload.php";
use Amp\ByteStream;
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);
yield $process->start();
echo yield ByteStream\buffer($process->getStdout());
$code = yield $process->join();
echo "Process exited with {$code}.\n";
});