1. Go to this page and download the library: Download yandy/laravel-grpc library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
yandy / laravel-grpc example snippets
namespace App\RpcClient;
use App\Grpc\HiReply;
use App\Grpc\HiUser;
class UserClient extends \Grpc\BaseStub{
public function __construct($hostname, $opts, $channel = null) {
parent::__construct($hostname, $opts, $channel);
}
//测试grpc客户端
public function sayHello(HiUser $argument,$metadata=[],$options=[]){
return $this->_simpleRequest('/grpc.hi/sayHello',
$argument,
['\App\Grpc\HiReply', 'decode'],
$metadata, $options);
}
}