【发布时间】:2016-11-06 05:27:09
【问题描述】:
我正在尝试在 Laravel 项目中使用 grpc。
这是我的 composer.json 文件的一部分:
"require": {
...
"datto/protobuf-php": "dev-master",
"google/auth": "^0.7.0",
"grpc/grpc": "dev-release-0_13",
...
}
我已经从我的 proto 文件生成了一个 php 文件。它位于 app/services/ 并包含在 composer.json autoload.files 部分中。我已经运行 composer install 没有问题。
我已经创建了一条测试路线。它有以下代码:
$client = new vat_service\VatServiceClient('localhost:50051', [
'credentials' => Grpc\ChannelCredentials::createInsecure()
]);
但是当我访问该路线时,我收到了回复Class 'Grpc\ChannelCredentials' not found.。
Laravel 应用在 Homestead vagrant box 中运行。
我不知道该怎么做。我是否缺少依赖项?我错过了安装什么吗?
【问题讨论】:
-
你也试过
\Grpc\ChannelCredentials吗? -
如果特定模块存在,还要检查您的供应商文件夹。
-
我现在尝试了 \Grpc\ChannelCredentials Sugato,仍然遇到同样的错误。
-
vendor文件夹中有一个grpc文件夹。当我搜索“ChannelCredentials”时,除了我自己的代码行,我什么也没找到。
-
嗯,这就是问题所在。如果您使用 netbeans,您可以执行“使用 \Grpc\”并按 ctrl + 空格键查看可用的类。