小编yan*_*a35的帖子

如何在 php 中初始化 Cloud Firestore?

我按照这些教程在 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=*}”,而是得到空提供的绑定:数组([project ] => [database] => (default) ) 在 C:\wamp64\www\php\vendor\google\gax\src\ResourceTemplate\RelativeResourceTemplate.php 第 238 行'

这是我的代码:

作曲家.json:

 {
    "require": {
        "google/cloud-firestore": "^1.4",
        "grpc/grpc": "v1.19.0"
    }
}
Run Code Online (Sandbox Code Playgroud)

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' …
Run Code Online (Sandbox Code Playgroud)

php firebase google-api-php-client grpc google-cloud-firestore

3
推荐指数
1
解决办法
3961
查看次数