2017-01-11 19:24:02 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
include dirname(__DIR__) . "/vendor/autoload.php";
|
|
|
|
|
2018-07-18 23:03:51 +02:00
|
|
|
use Amp\ByteStream\ResourceOutputStream;
|
2017-06-15 19:52:07 +02:00
|
|
|
use Amp\Process\Process;
|
2017-01-11 19:24:02 +01:00
|
|
|
|
2018-07-18 23:03:51 +02:00
|
|
|
// "echo" is a shell internal command on Windows and doesn't work.
|
|
|
|
$command = DIRECTORY_SEPARATOR === "\\" ? "cmd /c echo Hello World!" : "echo 'Hello, world!'";
|
2017-09-17 19:07:13 +02:00
|
|
|
|
2018-07-18 23:03:51 +02:00
|
|
|
$process = new Process($command);
|
|
|
|
$process->start();
|
2017-01-11 19:24:02 +01:00
|
|
|
|
2018-07-18 23:03:51 +02:00
|
|
|
$stdout = new ResourceOutputStream(STDOUT);
|
|
|
|
Amp\ByteStream\pipe($process->getStdout(), $stdout);
|
2017-01-11 19:24:02 +01:00
|
|
|
|
2018-07-18 23:03:51 +02:00
|
|
|
$exitCode = $process->join();
|
|
|
|
echo "Process exited with {$exitCode}." . PHP_EOL;
|