Esempio n. 1
0
function greet($name)
{
    $client = new helloworld\GreeterClient('localhost:50051', []);
    $request = new helloworld\HelloRequest();
    $request->setName($name);
    list($reply, $status) = $client->SayHello($request)->wait();
    $message = $reply->getMessage();
    return $message;
}
Esempio n. 2
0
function greet($name)
{
    $client = new helloworld\GreeterClient('localhost:50051', ['credentials' => Grpc\ChannelCredentials::createInsecure()]);
    $request = new helloworld\HelloRequest();
    $request->setName($name);
    list($reply, $status) = $client->SayHello($request)->wait();
    $message = $reply->getMessage();
    return $message;
}
<?php

//phpinfo();
require __DIR__ . '/../grpc/examples/php/vendor/autoload.php';
require __DIR__ . '/../helloworld.php';
$client = new helloworld\GreeterClient('0.0.0.0:50051', []);
$req = new helloworld\HelloRequest();
$req->setName('Daniel');
list($reply, $status) = $client->SayHello($req)->wait();
echo "<pre>" . $reply->getMessage() . "</pre>";
?>