-
-
Notifications
You must be signed in to change notification settings - Fork 27
Quickstart PHP (For Non Hyperf Users)
谷溪 edited this page Mar 28, 2020
·
4 revisions
<?php
declare(strict_types=1);
use Reasno\GoTask\Relay\CoroutineSocketRelay;
use Spiral\Goridge\RelayInterface;
use Spiral\Goridge\RPC;
use Swoole\Process;
use function Swoole\Coroutine\run;
require '../vendor/autoload.php';
$process = new Process(function (Process $process) {
$process->exec(__DIR__ . '/../app', ['-address', '127.0.0.1:6001']);
});
$process->start();
sleep(1);
run(function () {
$task = new RPC(
new CoroutineSocketRelay('127.0.0.1', 6001)
);
var_dump($task->call('App.Hi', 'Reasno'));
});
Full working demo: https://github.com/Reasno/gotask/blob/master/example/Client.php