caibao/grpc_client

1.0.0 2018-06-25 06:30 UTC

This package is auto-updated.

Last update: 2024-04-12 09:09:22 UTC


README

GrpcClient is a php client for grpc server depend on grpc_php_plugin. Making it easier for you to use grpc services.

Requirement

  1. PHP >= 5.6
  2. Composer
  3. grpc extension
  4. protoc(protobuf compiler)
  5. google/protobuf(protobuf runtime library package)
  6. grpc_php_plugin(PHP Protoc Plugin): Generates PHP gRPC service interface out of Protobuf IDL

Installation

composer require lat/grpcClient

Install protoc

  1. download the protoc binaries from the protocol buffers GitHub repository. Then unzip this file and Update the environment variable PATH to include the path to the protoc binary file.
  2. compile protoc from source
$ git clone -b $(curl -L https://grpc.io/release) https://github.com/grpc/grpc
$ cd grpc
$ git submodule update --init
$ cd grpc/third_party/protobuf
$ ./autogen.sh && ./configure && make
$ sudo make install

Install PHP Protoc Plugin

$ git clone -b $(curl -L https://grpc.io/release) https://github.com/grpc/grpc
$ cd grpc
$ git submodule update --init
$ make grpc_php_plugin

Compile proto file

# write the path of grpc_php_plugin
$ vim plugin.conf
$ ./create_client.sh

Usage

$clinet = GrpcServer\ClientFactory::createClient('sms.SMS', 'develop');
$clinet->SendVerificationCode();