I'm planning to combine PHP, GAE, and Firebase Database.
I tried using Firebase Admin SDK for PHP, following these instructions.
Then, I saw these two codes:
use Kreait\Firebase\Factory;
use Kreait\Firebase\ServiceAccount;
$serviceAccount =
ServiceAccount::fromJsonFile(__DIR__.'/firebase_credentials.json');
$firebase = (new Factory)
->withServiceAccount($serviceAccount)
->create();
use Kreait\Firebase\Factory;
use Kreait\Firebase\ServiceAccount;
$serviceAccount = ServiceAccount::fromJsonFile(__DIR__.'/google-service-account.json');
$apiKey = '<Firebase Web API key>';
$firebase = (new Factory)
->withServiceAccountAndApiKey($serviceAccount, $apiKey)
->create();
I tried to install firebase_credentials.json
manually, and have great results.
However... should I use Google Service Account Credentials to use User Management?
I know it says it in the documentation, but what is the difference between the following?
firebase_credentials.json
google-service-account.json
I will be planning to use Firebase JWT in the future. So, it probably would help to get some advice.
First of all, thanks for considering the library for your project. I updated the documentation since the time of your question and hope that it is a little bit clearer now. Also, it is not necessary anymore to provide the web API key to enable user management, you can just use the downloaded credentials file and everything will work fine.
To answer your question: firebase_credentials.json
and google-service-account.json
reference the same kind of credentials file, meaning the one that you can download in the Service Accounts tab in your project's settings page.
With any of the available Admin SDKs, this enables full administrative access to a project, so you should handle it with care.
Please note that since your question, a new major release has been published, and the usage instructions have changed (but not much). You can find the updated documentation at https://firebase-php.readthedocs.io .