rookiexxk / hyperf-firebase
Hyperf的Firebase PHP Admin SDK包
v1.0
2024-03-06 11:25 UTC
Requires
- php: >=8.1
- hyperf/cache: ~3.1.0
- hyperf/guzzle: ~3.1.0
- hyperf/logger: ~3.1.0
- hyperf/utils: ~3.1.0
- kreait/firebase-php: ^7.0
- symfony/cache: ^5.4|^6.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- phpstan/phpstan: ^1.0
- swoole/ide-helper: dev-master
This package is not auto-updated.
Last update: 2024-09-19 12:32:11 UTC
README
为Firebase PHP Admin SDK提供的Hyperf包。
安装
composer require rookiexxk/hyperf-firebase
发布
php bin/hyperf.php vendor:publish fcorz/hyperf-firebase
配置
使用JSON文件进行认证
FIREBASE_CREDENTIALS=config/certificates/service-account-file.json
用法
外观
use Fcorz\Hyperf\Firebase\Facades\Firebase; // Return an instance of the Messaging component for the default Firebase project $defaultMessaging = Firebase::messaging(); // Return an instance of the Auth component for a specific Firebase project $appMessaging = Firebase::project('app')->messaging(); $anotherAppMessaging = Firebase::project('another-app')->messaging(); // send message $message = [ 'token' => $deviceToken, 'notification' => [/* Notification data as array */], // optional 'data' => [/* data array */], // optional ]; Firebase::messaging()->send($message);
依赖注入
use Fcorz\Hyperf\Firebase\ApplicationProxy; class yourProjectFirebase extends ApplicationProxy { protected string $name = 'project_name'; } // send message class yourClass { public function __construct(yourProjectFirebase $firebase) { $firebase->messaging()->send($message); } }
Firebase Admin PHP SDK的未来
请阅读关于Firebase Admin PHP SDK未来的信息,请访问SDK的GitHub仓库。