我按照这些教程在PHP中使用Firestore:https : //github.com/googleapis/google-cloud-php-firestore https://firebase.google.com/docs/firestore/quickstart但是当我加载页面时,将显示以下消息:Google \ ApiCore \ ValidationException:呈现'projects / {project = } / databases / {database = }'时出错:预期的绑定'project'与段'{project = *}'匹配,但为空提供的绑定:Array([project ] => [database] =>(默认)),位于第238行的C:\ wamp64 \ www \ php \ vendor \ google \ gax \ src \ ResourceTemplate \ RelativeResourceTemplate.php中这是我的代码:composer.json: { "require": { "google/cloud-firestore": "^1.4", "grpc/grpc": "v1.19.0" }}index.php(示例副本):require ('vendor/autoload.php');use Google\Cloud\Firestore\FirestoreClient;/** * Initialize Cloud Firestore with default project ID. * ``` * initialize(); * ``` */ // Create the Cloud Firestore client $db = new FirestoreClient(); printf('Created Cloud Firestore client with default project ID.' . PHP_EOL);$docRef = $db->collection('users')->document('lovelace');$docRef->set([ 'first' => 'Ada', 'last' => 'Lovelace', 'born' => 1815]);
1 回答
![?](http://img1.sycdn.imooc.com/54584cd10001404b02200220-100-100.jpg)
30秒到达战场
TA贡献1828条经验 获得超6个赞
您似乎没有设置默认的项目ID。
尝试将GCLOUD_PROJECT环境变量设置为您的项目ID。
set GCLOUD_PROJECT=PROJECT_ID
您还可以尝试设置项目ID,如下所示:
$db = new FirestoreClient([
'projectId' => 'my-project-id',
]);
- 1 回答
- 0 关注
- 116 浏览
添加回答
举报
0/150
提交
取消