mirror of
https://github.com/danog/process.git
synced 2024-11-26 20:24:43 +01:00
20 lines
509 B
PHP
20 lines
509 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";
|
|
});
|