Skip to content

Instantly share code, notes, and snippets.

@gistlyn gistlyn/main.php
Created Dec 31, 2019

Embed
What would you like to do?
PHP Google protoc SSL GrpcServicesClient TodoWorld Example
<?php
require dirname(__FILE__).'/vendor/autoload.php';
@include_once dirname(__FILE__).'/GPBMetadata/Services.php';
@include_once dirname(__FILE__).'/TodoWorld/GrpcServicesClient.php';
@include_once dirname(__FILE__).'/TodoWorld/Hello.php';
@include_once dirname(__FILE__).'/TodoWorld/HelloResponse.php';
$client = new TodoWorld\GrpcServicesClient('todoworld.servicestack.net:50051', [
'credentials' => Grpc\ChannelCredentials::createSsl(file_get_contents('grpc.crt')),
]);
$request = new TodoWorld\Hello();
$request->setName("gRPC PHP");
list($reply, $status) = $client->GetHello($request)->wait();
if ($status->code !== Grpc\STATUS_OK) {
echo "Call did not complete successfully. Status object:\n";
var_dump($status);
exit(1);
}
echo $reply->getResult();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.