生成PHP语言的 ProtoBuffer、gRPC 文件
docker run --rm \
-v $(pwd):$(pwd) \
-w $(pwd) znly/protoc \
--php_out=./ \
--grpc_out=./ \
--plugin=protoc-gen-grpc=/usr/bin/grpc_php_plugin \
-I ./ \
user.proto \
执行后的文件格式
user.proto 示例:
syntax = "proto3";
package go.micro.service.user;
service User {
//注册
rpc Register(UserRegisterRequest) returns (UserRegisterResponse) {}
//登录
rpc Login(UserLoginRequest) returns(UserLoginResponse) {}
//获取用户
rpc GetUserInfo(UserInfoRequest) returns (UserInfoResponse) {}
}
message UserRegisterRequest {
string user_name = 1;
string first_name = 2;
string pwd = 3;
}
message UserRegisterResponse {
string message = 1;
}
message UserLoginRequest {
string user_name = 1;
string pwd = 2;
}
message UserLoginResponse {
bool is_success = 1;
}
message UserInfoRequest {
string user_name = 1;
}
message UserInfoResponse {
int64 user_id = 1;
string user_name = 2;
string first_name = 3;
}