Firebase Admin SDK for PHP¶
Important
Support the project: This SDK is downloaded 1M+ times monthly and powers thousands of applications. If it saves you or your team time, please consider sponsoring its development.
Note
If you are interested in using the PHP Admin SDK as a client for end-user access (for example, in a web application), as opposed to admin access from a privileged environment (like a server), you should instead follow the instructions for setting up the client JavaScript SDK.
Overview¶
Firebase provides the tools and infrastructure you need to develop your app, grow your user base, and earn money. The Firebase Admin PHP SDK enables access to Firebase services from privileged environments (such as servers or cloud) in PHP.
Installation¶
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.
composer require "kreait/firebase-php:^7.0" Please continue to the Setup section to learn more about connecting your application to Firebase.
If you want to use the SDK within a Framework, please follow the installation instructions here:
Laravel: kreait/laravel-firebase
Symfony: kreait/firebase-bundle
Quick Start¶
use Kreait\Firebase\Factory; $factory = (new Factory) ->withServiceAccount('/path/to/firebase_credentials.json') ->withDatabaseUri('https://my-project-default-rtdb.firebaseio.com'); $auth = $factory->createAuth(); $realtimeDatabase = $factory->createDatabase(); $cloudMessaging = $factory->createMessaging(); $remoteConfig = $factory->createRemoteConfig(); $cloudStorage = $factory->createStorage(); $firestore = $factory->createFirestore(); License¶
Licensed using the MIT license.
Copyright (c) Jérôme Gamez <https://github.com/jeromegamez> <jerome@gamez.name>
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.
Your use of Firebase is governed by the Terms of Service for Firebase Services.