首页 > 解决方案 > 找不到类“Grpc\BaseStub”

问题描述

尝试运行由protoc一堆*.proto文件生成的 PHP 客户端代码。PHP 代码在带有 php7.3 的 docker 容器上运行,并安装并启用了 GRPC 扩展:pecl/grpc is already installed and is the same as the released version 1.23.1.

当代码运行时,我收到以下错误:Class 'Grpc\BaseStub' not found.

此行触发了错误:class ProductServiceClient extends \Grpc\BaseStub {. 这是自动生成代码中的一行,因此无法修改。

[编辑] 运行composer require grpc/grpc解决了这个问题;但是,我现在有Class 'Google\Protobuf\Internal\Message' not found.

[编辑] 运行composer require google/protobuf解决了第二个问题。

标签: phpgrpc

解决方案


尝试添加 grpc 库:

composer require grpc/grpc

推荐阅读