Skip to content

Quickstart PHP (For Non Hyperf Users)

Reasno edited this page Apr 10, 2020 · 4 revisions
<?php

declare(strict_types=1);

use Hyperf\GoTask\IPC\SocketIPC;
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 SocketIPCSender('127.0.0.1:6001');
    var_dump($task->call('App.Hi', 'Hyperf'));
});

Full working demo: https://github.com/Hyperf/gotask/blob/master/example/Client.php

Clone this wiki locally