php - 没有从 Firestore 检索到文档
问题描述
我想从 Cloud Firestore 中检索数据,但我做不到,也不知道从哪里开始。我尝试了参考在 Firestore 中开始的代码,但未获取数据。这是我的代码
<?php
require __DIR__.'/vendor/autoload.php';
use Google\Cloud\Firestore\FirestoreClient;
$db = new FirestoreClient(
[
'projectId' => 'fakedata-aa798'
]
);
$collectionReference = $db->collection('Test3')->document('User1');
$snapshot = $collectionReference->snapshot();
if ($snapshot->exists()) {
print_r($snapshot->data());
} else {
printf('Document %s does not exist!' . PHP_EOL, $snapshot->id());
}
?>
如何从 Firestore 中获取数据?帮帮我,我不知道如何在我的环境开发中设置 GOOGLE_APPLICATION_CREDENTIALS。
解决方案
推荐阅读
- java - 无法自动选择文件通过使用 Selenium Webdriver
- python - Python 在函数中使用 [0] 传递变量
- c++ - 混合 C++ 和程序集不能将多个参数从 C++ 函数传递到程序集
- python-3.x - 在工作人员之间发送 Aiohttp Websocket 消息
- ios - 如何快速使用 Microsoft Speech API:iOS Speech-to-Text 客户端库?
- python - 每次在python中调用函数时在函数内循环一个变量
- swift - ios中单个金属层中的多个纹理
- javascript - 是否可以在电子应用程序中从相机流式传输 RTSP(实时)视频?
- sql-server - MultiSubnetFailover 不适用于 Windows 中的 ODBC13/17
- powershell - 409:使用 REST API 在 Artifactory 中复制工件时发生冲突错误