Search code examples
phpprotocol-buffers

protobuf compiler doesnt service compiler in php


Why are services not compiled in php?

my proto file content

syntax = "proto3";

service SearchService {
  rpc Search(SearchRequest) returns (stream SearchResponse);
}

message SearchRequest{
  string q = 1;
}

message SearchResponse{
  string result = 1;
}

and I run the following command

protoc  --php_out=src proto/example.proto

as a result, SeachRequest and SearchResponse objects have been created but the SearchService did not have been created


Solution

  • after a few days, I found the answer in a random repo. I noticed --grpc_out= flag is missing ,in addition --plugin=protoc-gen-grpc=$(which grpc_php_plugin) is missing the console command should have such as bellow

    protoc --php_out=./src --grpc_out=./src --plugin=protoc-gen-grpc=$(which grpc_php_plugin) ./protos/example.proto
    
    

    I even created an example for it.. php gRPC server and client