我正在尝试在 Laravel 项目中使用 grpc。
这是我的composer.json 文件的一部分:
"require": {
...
"datto/protobuf-php": "dev-master",
"google/auth": "^0.7.0",
"grpc/grpc": "dev-release-0_13",
...
}
Run Code Online (Sandbox Code Playgroud)
我已经从我的 proto 文件生成了一个 php 文件。它位于 app/services/ 中并包含在composer.jsonautoload.files部分中。我运行composer install没有问题。
我已经创建了一条测试路线。它有以下代码:
$client = new vat_service\VatServiceClient('localhost:50051', [
'credentials' => Grpc\ChannelCredentials::createInsecure()
]);
Run Code Online (Sandbox Code Playgroud)
Class 'Grpc\ChannelCredentials' not found.但当我访问路线时我收到了回复。
Laravel 应用程序在 Homestead vagrant box 中运行。
我不知道如何继续。我缺少依赖吗?我是否错过了安装某些东西?