gRPC 一遍又一遍地出现相同的错误“--grpc_out:protoc-gen-grpc:系统找不到指定的路径。”

问题描述 投票:0回答:1

我正在关注此链接的快速入门:https://grpc.io/docs/languages/php/quickstart/

我一次又一次地执行此步骤 3 或 4 次,但我总是停留在同一点。

当我需要跑步时:

protoc --proto_path=examples/protos --php_out=examples/php --grpc_out=examples/php --plugin=protoc-gen-grpc=bins/opt/grpc_php_plugin ./examples/protos/helloworld.proto

我收到错误:

--grpc_out: protoc-gen-grpc: 系统找不到指定的路径。

我可以运行这样的东西,它将与服务器建立连接(我在 gRPC 服务器上收到预期的日志):

协议 --proto_path=examples/protos --php_out=examples/php ./examples/protos/helloworld.proto

我已经安装了 protoc 并且它位于 PATH 中,我可以运行 protoc --version。我在 comoser.json 中有这个

“要求”:{ "grpc/grpc": "^v1.39.0", “谷歌/protobuf”:“^v3.12.2” },

我尝试过的PHP版本是:7.4、8.0、8.1、8.2。我使用的是 Windows 10。

任何人都可以帮助我解决这个问题,或者只是尝试给我一些建议,看看和检查什么,我是 gRPC 的新手。

谢谢大家!!

php laravel protocol-buffers grpc
1个回答
0
投票

我遵循这些说明并使用

health.proto
作为示例。 之前:

tree ${HOME}/examples
~/examples
└── health.proto

并且:

WORK="${HOME}/grpc/cmake/build"

${WORK}/third_party/protobuf/protoc \
--plugin=protoc-gen-grpc=${WORK}/grpc_php_plugin \
--proto_path=${HOME}/examples \
--php_out=${HOME}/examples \
--grpc_out=${HOME}/examples \
${HOME}/examples/health.proto

注意

    为了清晰起见,使用了
  • WORK
    HOME
  • 一旦定义了
    --proto_path
    (即
    ${HOME}/examples
    ),就必须对与其相关的protobuf源重复该定义(即
    ${HOME}/examples/health.proto
    ) 之后:
tree ${HOME}/examples
~/examples
├── GPBMetadata
│   └── Health.php
├── Grpc
│   └── Health
│       └── V1
│           ├── HealthCheckRequest.php
│           ├── HealthCheckResponse
│           │   └── ServingStatus.php
│           ├── HealthCheckResponse.php
│           └── HealthClient.php
└── health.proto
© www.soinside.com 2019 - 2024. All rights reserved.