caibao / grpc_client
grpc_client
1.0.0
2018-06-25 06:30 UTC
Requires
- google/protobuf: ^3.3
- grpc/grpc: ^1.4
This package is auto-updated.
Last update: 2024-09-12 09:57:14 UTC
README
GrpcClient 是一个依赖于 grpc_php_plugin 的 gRPC 服务器客户端(PHP)。它使您更容易使用 gRPC 服务。
需求
- PHP >= 5.6
- Composer
- grpc 扩展
- protoc(protobuf 编译器)
- google/protobuf(protobuf 运行时库包)
- grpc_php_plugin(PHP Protoc 插件):从 Protobuf IDL 生成 PHP gRPC 服务接口
安装
composer require lat/grpcClient
安装 protoc
- 从协议缓冲区 GitHub 存储库下载 protoc 二进制文件。缓冲区 GitHub 仓库。然后解压缩此文件,并更新环境变量 PATH 以包含 protoc 二进制文件的路径。
- 从源代码编译 protoc
$ git clone -b $(curl -L https://grpc.org.cn/release) https://github.com/grpc/grpc $ cd grpc $ git submodule update --init $ cd grpc/third_party/protobuf $ ./autogen.sh && ./configure && make $ sudo make install
安装 PHP Protoc 插件
$ git clone -b $(curl -L https://grpc.org.cn/release) https://github.com/grpc/grpc $ cd grpc $ git submodule update --init $ make grpc_php_plugin
编译 proto 文件
# write the path of grpc_php_plugin
$ vim plugin.conf
$ ./create_client.sh
用法
$clinet = GrpcServer\ClientFactory::createClient('sms.SMS', 'develop');
$clinet->SendVerificationCode();