kreait/firebase-bundle 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

kreait/firebase-bundle

Composer 安装命令:

composer require kreait/firebase-bundle

包简介

Symfony Bundle for the Firebase Admin SDK

README 文档

README

A Symfony Bundle for the Firebase PHP SDK.

Current version Monthly Downloads Total Downloads Tests Sponsor

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 kreait to the beste GitHub Organization in January 2026. The namespace remains Kreait\Firebase\Symfony\Bundle and the package name remains kreait/firebase-bundle. Please update your remote URL if you have forked or cloned the repository.

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.

For more information, visit the Firebase Admin PHP SDK documentation.

Installation

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],
];

Configuration

Minimal

# 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_check
  • kreait_firebase.my_project.auth
  • kreait_firebase.my_project.database
  • kreait_firebase.my_project.firestore
  • kreait_firebase.my_project.messaging
  • kreait_firebase.my_project.remote_config
  • kreait_firebase.my_project.storage
  • kreait_firebase.other_project.*

The following classes will be available for dependency injection if you have configured only one project:

  • Kreait\Firebase\Contract\AppCheck
  • Kreait\Firebase\Contract\Auth
  • Kreait\Firebase\Contract\Database
  • Kreait\Firebase\Contract\Firestore
  • Kreait\Firebase\Contract\Messaging
  • Kreait\Firebase\Contract\RemoteConfig
  • Kreait\Firebase\Contract\Storage

To 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 $myProjectAppCheck
  • Kreait\Firebase\Contract\Auth $myProjectAuth
  • Kreait\Firebase\Contract\Database $myProjectDatabase
  • Kreait\Firebase\Contract\Firestore $myProjectFirestore
  • Kreait\Firebase\Contract\Messaging $myProjectMessaging
  • Kreait\Firebase\Contract\RemoteConfig $myProjectRemoteConfig
  • Kreait\Firebase\Contract\Storage $myProjectStorage

Full

# 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

Documentation

For documentation of the underlying SDK, visit the Firebase Admin PHP SDK documentation.

License

This project is licensed under the MIT License.

Your use of Firebase is governed by the Terms of Service for Firebase Services.

kreait/firebase-bundle 适用场景与选型建议

kreait/firebase-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5.05M 次下载、GitHub Stars 达 155, 最近一次更新时间为 2015 年 01 月 23 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「database」 「symfony」 「api」 「bundle」 「google」 「sdk」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 kreait/firebase-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 kreait/firebase-bundle 我们能提供哪些服务?
定制开发 / 二次开发

基于 kreait/firebase-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 5.05M
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 155
  • 点击次数: 19
  • 依赖项目数: 2
  • 推荐数: 1

GitHub 信息

  • Stars: 155
  • Watchers: 6
  • Forks: 29
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-01-23