Bellal Mohamed
Bellal Mohamed

Reputation: 67

What is the reason for this connection error on google cloud firestore-php?

I'm following the official docs to setup google cloud firestore to integrate with my php project

[1] https://cloud.google.com/firestore/docs/quickstart-servers

when I initialize the FirestoreClient I get the following error

Error rendering 'projects/{project=*}/databases/{database=*}': expected binding 'project' to match segment '{project=*}', instead got null\n
Provided bindings: Array\n
(\n
    [project] => \n
    [database] => (default)\n
)\n

First In the documentation it tells to use ENV VARIABLE though using the following command export GOOGLE_APPLICATION_CREDENTIALS=/Users/user/Desktop/programming/workarea/.firebase.config.json

I investigated a lot and I think the problem happens when the library tries to establish a connection with the firestore server.

I couldn't find the root of the problem. but I think for some reason the php server not reading the env vars so it's not able to establish a proper connection

Upvotes: 2

Views: 1074

Answers (1)

I struggled some time with this too, resolved it after realizing this: as said here, you first have to authenticate. For that, install the gcloud-sdk available here, then follow the steps provided.

Second, you have to set your environment variable with the path to your project's credentials file, as you were doing, in the bash (i use ~/.bashrc), exit the terminal and reenter it (necessary, as it may not apply the file edit for that terminal session). You could also type source .bashrc to apply changes without closing the terminal.

Then you should be fine, assuming you have the other required environment dependencies installed found here.

Upvotes: 1

Related Questions