Skip to content

Instantly share code, notes, and snippets.

@gistlyn
Created December 31, 2019 03:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gistlyn/601b972a4e48322b7ecceebc461e65e4 to your computer and use it in GitHub Desktop.
Save gistlyn/601b972a4e48322b7ecceebc461e65e4 to your computer and use it in GitHub Desktop.
PHP Google protoc insecure 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:5054', [
'credentials' => Grpc\ChannelCredentials::createInsecure(),
]);
$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