Created
December 31, 2019 03:30
-
-
Save gistlyn/6bde17c5a7b6bbe59a1c8e267a8b4337 to your computer and use it in GitHub Desktop.
PHP Google protoc SSL GrpcServicesClient TodoWorld Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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