https://github.com/cjyzwg/grpc-php
grpc server:go,client:php/go
https://github.com/cjyzwg/grpc-php
grpc grpc-client grpc-php
Last synced: 5 months ago
JSON representation
grpc server:go,client:php/go
- Host: GitHub
- URL: https://github.com/cjyzwg/grpc-php
- Owner: cjyzwg
- Created: 2019-09-14T16:48:15.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-02-24T23:02:44.000Z (over 3 years ago)
- Last Synced: 2024-06-20T07:55:31.963Z (almost 2 years ago)
- Topics: grpc, grpc-client, grpc-php
- Language: PHP
- Homepage:
- Size: 18.6 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# grpc php client
**服务端取的是https://www.jianshu.com/p/7fe7a8507745 案例**
#### 需要执行
> export GO111MODULE=on
go mod tidy
#### 安装依赖
>pecl install grpc
pecl install protobuf
同时并.so 文件放进ini中,如果是在docker中使用docker-php-ext-enable grpc,docker-php-ext-enable protobuf
wget https://github.com/google/protobuf/releases/download/v3.5.1/protobuf-all-3.5.1.zip
unzip protobuf-all-3.5.1.zip
cd protobuf-3.5.1/
./configure
make
make install
protoc --version
出现make 错误,安装apt-get install automake
ldconfig
1、protoc --proto_path=../../ --php_out=. helloServer.proto
2、在client/phpclient/Rpc_proto 文件夹新建HelloClient.php
_simpleRequest('/rpc_proto.HelloServer/SayHello',
$argument,
['\Rpc_proto\HelloReply', 'decode'],
$metadata, $options);
}
public function GetHelloMsg(\Rpc_proto\HelloRequest $argument,$metadata=[],$options=[]){
return $this->_simpleRequest('/rpc_proto.HelloServer/GetHelloMsg',
$argument,
['\Rpc_proto\HelloMessage', 'decode'],
$metadata, $options);
}
}
?>
3、cd client/phpclient && composer install
4、cd server && go run server.go
5、新建hello.php,并执行php hello.php
结果:
> helloGreenHat
this is from server HAHA!