- PHP >= 7.4
- The mbstring PHP extension
- A Firebase project - create a new project in the Firebase console, if you don’t already have one.
- A Google service account, follow the instructions in the official Firebase Server documentation and place the JSON configuration file somewhere in your project’s path.
The recommended way to install the Firebase Admin SDK is with Composer. Composer is a dependency management tool for PHP that allows you to declare the dependencies your project needs and installs them into your project.
If you want to use the SDK within a Framework, please follow the installation instructions here:
composer require kreait/firebase-php
After installing, you need to require Composer’s autoloader:
<?php require __DIR__.'/vendor/autoload.php';
You can find out more on how to install Composer, configure autoloading, and other best-practices for defining dependencies at getcomposer.org.
Please continue to the Setup section to learn more about connecting your application to Firebase.
You can find usage examples at https://github.com/jeromegamez/firebase-php-examples and in the tests directory of this project’s GitHub repository.
Licensed using the MIT license.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- The SDK utilizes PSR-4, PSR-7 and PSR-12.
- This SDK has a minimum PHP version requirement of PHP 7.4.
- All pull requests should include unit tests to ensure the change works as expected and to prevent regressions.
Running the tests¶
The SDK is unit tested with PHPUnit. Run the tests using the Makefile: