laravel-firebase: Initialize error 'Unable to create a FirestoreClient: Error rendering...'

Hello.

This library is very easy to use. I thank you.

It’s working is 2 days ago. Not working today.

I don’t change files .env and firebase_credential.json. Please let me know if you have any cause.

error message:

Kreait\Firebase\Exception\RuntimeException  : Unable to create a FirestoreClient: Error rendering 'projects/{project=*}/databases/{database=*}': expected binding 'project' to match segment '{project=*}', instead got null
Provided bindings: Array
(
    [project] =>
    [database] => (default)
)


  at /home/mirasapo_admin/wordpress/src/laravel/vendor/kreait/firebase-php/src/Firebase/Factory.php:350
    346|
    347|         try {
    348|             return new FirestoreClient($config);
    349|         } catch (Throwable $e) {
  > 350|             throw new RuntimeException('Unable to create a FirestoreClient: '.$e->getMessage(), $e->getCode(), $e);
    351|         }
    352|     }
    353|
    354|     public function createStorage(array $storageClientConfig = null): Storage

Version:

...
google/auth                           v1.6.1     Google Auth Library for PHP
google/cloud-core                     v1.34.0    Google Cloud PHP shared dependency, providing functionality useful to all components.
google/cloud-firestore                v1.10.0    Cloud Firestore client for PHP
google/cloud-storage                  v1.16.0    Cloud Storage Client for PHP
google/common-protos                  1.1        Google API Common Protos for PHP
google/crc32                          v0.1.0     Various CRC32 implementations
google/gax                            1.2.0      Google API Core for PHP
google/grpc-gcp                       0.1.4      gRPC GCP library for channel management
google/protobuf                       v3.11.1    proto library for PHP
grpc/grpc                             1.25.0     gRPC library for PHP

...
kreait/clock                          1.0.1      A PHP 7.0 compatible clock abstraction
kreait/firebase-php                   4.36.2     Firebase Admin SDK
kreait/firebase-tokens                1.9.2      A library to work with Firebase tokens
kreait/gcp-metadata                   1.0.1      Get the metadata from a Google Cloud Platform environment.
kreait/laravel-firebase               1.2.0      A Laravel package for the Firebase PHP Admin SDK
...

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 15 (6 by maintainers)

Most upvoted comments

In Laravel, you could do for example:

$database = app('firebase.firestore')->database();

$var_list = $database->collection('tokens')->document('tokens')->snapshot();

Today I suddenly got this issue after run config:cache then I figured out that it only read FIREBASE CREDENTIALS in .env not GOOGLE_APPLICATION_CREDENTIALS

If you‘re satisfied with the outcome, of course 😃. Please fell free to create a new issue or ask on Discord if you have further questions!