1
0
mirror of https://github.com/danog/process.git synced 2024-12-11 08:39:41 +01:00
process/examples/basic-command.php

20 lines
509 B
PHP
Raw Normal View History

<?php
include dirname(__DIR__) . "/vendor/autoload.php";
2017-06-15 19:02:50 +02:00
use Amp\ByteStream\Message;
use Amp\Process\Process;
2017-06-15 19:11:38 +02:00
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());
2017-06-15 19:02:50 +02:00
$code = yield $process->join();
2017-01-15 16:30:34 +01:00
echo "Process exited with {$code}.\n";
});