kreait / firebase-bundle
Firebase Admin SDK 的 Symfony 扩展包
5.4.0
2024-07-08 08:56 UTC
Requires
- php: ~8.1.0 || ~8.2.0 || ~8.3.0
- kreait/firebase-php: ^7.0
- psr/simple-cache: ^1.0 || ^2.0 || ^3.0
- symfony/cache: ^5.4 || ^6.0 || ^7.0
- symfony/config: ^5.4 || ^6.0 || ^7.0
- symfony/dependency-injection: ^5.4 || ^6.0 || ^7.0
- symfony/http-kernel: ^5.4 || ^6.0 || ^7.0
Requires (Dev)
- phpunit/phpunit: ^9.5.10
This package is auto-updated.
Last update: 2024-09-13 19:58:24 UTC
README
这是一个为Firebase PHP SDK设计的 Symfony 扩展包。
Firebase Admin PHP SDK 的未来
请阅读SDK 的 GitHub 仓库关于 Firebase Admin PHP SDK 的未来。
概述
Firebase提供了您开发应用程序、增长用户基础和赚钱所需的所有工具和基础设施。Firebase Admin PHP SDK 允许从受保护的环境(如服务器或云)访问 Firebase 服务。
有关更多信息,请访问Firebase Admin PHP SDK 文档。
安装
使用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], ];
支持的版本
仅支持最新版本。
早期版本将收到安全修复,只要它们的最低 SDK 要求收到安全修复。您可以在SDK 的 README中找到当前支持的版本和支持选项。
配置
最小
# 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'
以下服务将可用于您的项目
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.my_project.dynamic_links
kreait_firebase.other_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
Kreait\Firebase\Contract\DynamicLinks
要使在存在多个项目时通过依赖注入在类的构造函数中使用类更容易,您可以在构造函数中这样做
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
Kreait\Firebase\Contract\DynamicLinks $myProjectDynamicLinks
完整
# 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: Default domain for Dynamic Links default_dynamic_links_domain: 'https://my_project.page.link' # Optional: Used to cache Google's public keys. 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 # If set, logs simple HTTP request and response statuses http_request_logger: null # Example: monolog.logger.firebase # If set, logs detailed HTTP request and response statuses http_request_debug_logger: null # Example: monolog.logger.firebase_debug
文档
有关底层 SDK 的文档,请访问Firebase Admin PHP SDK 文档。
许可
本项目采用MIT 许可证。
您对 Firebase 的使用受Firebase 服务条款的约束。