php class for message of imported proto file not generated
i tried to run protoc --php_out=test/ --php-grpc_out=test/ import/service.proto from inside the cmd/protoc-gen-php-grpc/testdata dir. everything worked, except for the PHP file of Sub\Message class is not generated. Message and ServiceInterface classes from namespace Import are fine. am i doing something wrong here?
Can you provide sample Proto file? What version did you use?
This seems to be one of the "gotchas" working with protoc: https://groups.google.com/forum/#!topic/protobuf/rRDqUT2ddYo
Currently you can run command like: protoc --php_out=test/ --php-grpc_out=test/ import/service.proto import/sub/message.proto
I'm digging into specifications.
More info: https://github.com/protocolbuffers/protobuf/issues/4176
I'm having the same problem, I'm trying to generate code with imported messages. Seems that the protoc-gen-php-grpc compiler totally ignores the imports. Here are my protos:
service.proto
syntax = "proto3";
package location;
import "common/graphql.proto"
message CityRequest {
int32 id = 1;
string lang = 2;
repeated common.GraphSelection selections = 3;
}
common/graphql.proto
syntax = "proto3";
package common;
message GraphSelection {
string name = 1;
repeated common.GraphSelection selections = 2;
}
The CityRequest interface is generated correctly with references to \Common\GraphSelection but no GraphSelection.php
Hi, i'm digging into this issue as well, it is actually not protoc-get-php-grpc limitation but rather protoc iself. You can see that it generate correct references but it never receives call from protoc to render other php files.
See for reference: https://github.com/golang/protobuf/issues/322
The solution is very easy - specify imports you want to render with original service.
FYI, messages are generated by native php-out plugin, not by php-grpc.
Example: protoc --php_out=./test/ import/service.proto
On linux you can also use * to specify multiple files.
I can propose an option to create vendor/bin/grpc-generate command which will automatically all included files.
This is implementation I use to bypass this problem in our framework: https://github.com/spiral/framework/blob/master/src/GRPC/ProtoCompiler.php
Also, in next 2 hours I will provide application bundle which simplifies GRPC application creation a lot: https://github.com/spiral/app-grpc
This is implementation I use to bypass this problem in our framework: https://github.com/spiral/framework/blob/master/src/GRPC/ProtoCompiler.php
Also, in next 2 hours I will provide application bundle which simplifies GRPC application creation a lot: https://github.com/spiral/app-grpc
Thank you for the solution, I think the issue can be closed now.