php - 尝试检索数据时未找到 google Firestore 的 php sdk 抛出错误“Google\Firestore\V1beta1\StructuredQuery\CollectionSelector”
问题描述
当我尝试从集合中提取数据时,我已经安装了 google fire 商店“google/cloud-firestore”的 php sdk,它会引发此错误
未捕获的错误:在 vendor/google/gax/src/Serializer.php:276 中找不到类“Google\Firestore\V1beta1\StructuredQuery\CollectionSelector”
我的实际代码是
// custom logic, just pulling the config array this part is working fine
$option = $ins->integration('firebase')->get_options();
$firestore = new FirestoreClient($option);
$chats = $firestore->collection('chats'); // this is where the error occurred
完整的错误跟踪是
Fatal error: Uncaught Error: Class 'Google\Firestore\V1beta1\StructuredQuery\CollectionSelector' not found in /vendor/google/gax/src/Serializer.php:276
Stack trace:
#0 /vendor/google/gax/src/Serializer.php(314): Google\GAX\Serializer->decodeElement(Object(Google\Protobuf\FieldDescriptor), Array)
#1 /vendor/google/gax/src/Serializer.php(103): Google\GAX\Serializer->decodeMessageImpl(Object(Google\Firestore\V1beta1\StructuredQuery), Object(Google\Protobuf\Descriptor), Array)
#2 /vendor/google/cloud-firestore/Connection/Grpc.php(168): Google\GAX\Serializer->decodeMessage(Object(Google\Firestore\V1beta1\StructuredQuery), Array)
#3 /vendor/google/cloud-firestore/Query.php(166): Google\Cloud\Firestore\Connection\Grpc-> in /vendor/google/gax/src/Serializer.php on line 276
在 Serializer 类中,引发错误的函数是这个
private function decodeElement(FieldDescriptor $field, $data)
{
switch ($field->getType()) {
case GPBType::MESSAGE:
if ($data instanceof \Google\Protobuf\Internal\Message) {
return $data;
}
$messageType = $field->getMessageType();
$klass = $messageType->getClass();
$msg = new $klass(); // this class is not found 'Google\Firestore\V1beta1\StructuredQuery\CollectionSelector'
return $this->decodeMessageImpl($msg, $messageType, $data);
default:
return $data;
}
}
我转储了 $klass 和 $data 变量,这是输出
string(59) "Google\Firestore\V1beta1\StructuredQuery\CollectionSelector"
array(1) {
["collectionId"]=>
string(5) "chats"
}
解决方案
这真的很奇怪,但我刚刚删除了供应商目录,并使用 --no-cache 标志重新运行作曲家,现在它可以工作了
推荐阅读
- shell - Unix shell 按日期时间范围和文本过滤
- vb.net - 如何让这个下载异步运行
- python - Python ctypes 具有变量类型的行为
- scala - 从 spark 数据框中的不同 ROW 获取值
- sql - 动态 SQL :: 计算每个索引的 NULL 百分比
- linear-regression - 了解线性回归
- sql-server - 将域凭据传递给 IIS 8.5 服务器 2012R2 上的 Python Flask 应用程序以使用可信连接连接到数据库
- asp.net-core - 错误:“在 SetAuthenticationState 之前调用了 GetAuthenticationStateAsync。”
- javascript - AJAX Dropbox 无法打开上传的文件
- azure - 如何通过 Powershell 为新的 Azure AD 应用程序配置 PreAuthorizedApplication?