blob: 683a23415c22129e7b8b59daa12155775b05615a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
<?php
/**
* Sample GRPC PHP server.
*/
use Service\EchoInterface;
use Spiral\Goridge\StreamRelay;
use Spiral\GRPC\Server;
use Spiral\RoadRunner\Worker;
require __DIR__ . '/vendor/autoload.php';
$server = new Server(null, [
'debug' => false, // optional (default: false)
]);
$server->registerService(EchoInterface::class, new EchoService());
$worker = \method_exists(Worker::class, 'create')
// RoadRunner >= 2.x
? Worker::create()
// RoadRunner 1.x
: new Worker(new StreamRelay(STDIN, STDOUT))
;
$server->serve($worker);
|