kreait/firebase-bundle
Symfony bundle integrating the Firebase Admin PHP SDK. Configure service accounts and access Firebase services (Auth, Firestore/Database, Messaging, Storage) via Symfony’s DI and configuration, with support for modern Symfony setups (Flex or manual).
A Symfony Bundle for the Firebase PHP SDK.
[!IMPORTANT] Support the project: The Firebase PHP 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] The project moved from the
kreaitto thebesteGitHub Organization in January 2026. The namespace remainsKreait\Firebase\Symfony\Bundleand the package name remainskreait/firebase-bundle. Please update your remote URL if you have forked or cloned the repository.
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.
For more information, visit the Firebase Admin PHP SDK documentation.
Add the bundle using Composer
composer require kreait/firebase-bundle
// Symfony without Flex
// in %kernel.root_dir%/AppKernel.php
$bundles = array(
// ...
new Kreait\Firebase\Symfony\Bundle\FirebaseBundle(),
);
// Symfony with Flex
// in config/bundles.php
return [
// ...
Kreait\Firebase\Symfony\Bundle\FirebaseBundle::class => ['all' => true],
];
# app/config/config.yml (Symfony without Flex)
# config/packages/firebase.yaml (Symfony with Flex)
kreait_firebase:
projects:
my_project:
credentials: '%kernel.project_dir%/config/my_project_credentials.json'
other_project: # optional
credentials: '%kernel.project_dir%/config/other_project_credentials.json'
The following services will be available for your project:
kreait_firebase.my_project.app_checkkreait_firebase.my_project.authkreait_firebase.my_project.databasekreait_firebase.my_project.firestorekreait_firebase.my_project.messagingkreait_firebase.my_project.remote_configkreait_firebase.my_project.storagekreait_firebase.other_project.*The following classes will be available for dependency injection if you have configured only one project:
Kreait\Firebase\Contract\AppCheckKreait\Firebase\Contract\AuthKreait\Firebase\Contract\DatabaseKreait\Firebase\Contract\FirestoreKreait\Firebase\Contract\MessagingKreait\Firebase\Contract\RemoteConfigKreait\Firebase\Contract\StorageTo make it easier to use classes via dependency injection in the constructor of a class when multiple projects exist, you can do this in the constructor:
Kreait\Firebase\Contract\AppCheck $myProjectAppCheckKreait\Firebase\Contract\Auth $myProjectAuthKreait\Firebase\Contract\Database $myProjectDatabaseKreait\Firebase\Contract\Firestore $myProjectFirestoreKreait\Firebase\Contract\Messaging $myProjectMessagingKreait\Firebase\Contract\RemoteConfig $myProjectRemoteConfigKreait\Firebase\Contract\Storage $myProjectStorage# app/config/config.yml (Symfony without Flex)
# config/packages/firebase.yaml (Symfony with Flex)
kreait_firebase:
projects:
my_project:
# Optional: Path to the project's Service Account credentials file
# If omitted, the credentials will be auto-discovered as described
# in https://firebase-php.readthedocs.io/en/stable/setup.html
credentials: '%kernel.project_dir%/config/my_project_credentials.json'
# Optional: Override the project being used
# If omitted, the project is automatically derived, e.g. from credentials
project_id: 'project-b'
# Optional: If set to true, this project will be used when
# type hinting the component classes of the Firebase SDK,
# e.g. Kreait\Firebase\Auth, Kreait\Firebase\Database,
# Kreait\Firebase\Messaging, etc.
default: false
# Optional: If set to false, the service and its alias can only be
# used via dependency injection, and not be retrieved from the
# container directly.
public: true
# Optional: Should only be used if the URL of your Realtime
# Database can not be generated with the project id of the
# given Service Account
database_uri: 'https://my_project.firebaseio.com'
# Optional: Make the client tenant aware
tenant_id: 'tenant-id'
# Optional: Used to cache Google's public keys for ID Token verification.
verifier_cache: null # Example: cache.app
# Optional: Used to cache the authentication tokens for connecting to the Firebase servers.
auth_token_cache: null # Example: cache.app
# Optional: Used to cache Google's public keys for AppCheck token verification.
key_set_cache: null # Example: cache.app
# Optional: Service id of Kreait\Firebase\Http\HttpClientOptions
# used to configure the SDK's HTTP client.
http_client_options: null # Example: app.firebase.http_client_options
For documentation of the underlying SDK, visit the Firebase Admin PHP SDK documentation.
This project is licensed under the MIT License.
Your use of Firebase is governed by the Terms of Service for Firebase Services.
How can I help you explore Laravel packages today?