codecovevienna/larafirebase
Composer 安装命令:
composer require codecovevienna/larafirebase
包简介
Laravel Firebase Cloud Messaging.
README 文档
README
Introduction
Larafirebase is a package thats offers you to send push notifications via Firebase in Laravel.
Firebase Cloud Messaging (FCM) is a cross-platform messaging solution that lets you reliably deliver messages at no cost.
For use cases such as instant messaging, a message can transfer a payload of up to 4KB to a client app.
Installation
Follow the steps below to install the package.
Install via Composer
composer require codecovevienna/larafirebase
Copy Configuration
Run the following command to publish the larafirebase.php config file:
php artisan vendor:publish --provider="CodeCoveVienna\Larafirebase\Providers\LarafirebaseServiceProvider"
Configure larafirebase.php as needed
Open the larafirebase.php configuration file, which you just published, and set the following values as needed:
project_id: Replace with your actual Firebase project ID.firebase_credentials: This refers to the JSON credentials file for your Firebase project. Make sure it points to the correct location in your project. This JSON file contains the authentication information for your Firebase project, allowing your Laravel application to interact with Firebase services. You can generate this JSON file in the Firebase Console. Once you have it, specify its path in this configuration.
Usage
Follow the steps below to find how to use the package.
Example usage in any class you want to use Larafirebase:
use CodeCoveVienna\Larafirebase\Facades\Larafirebase; class MyController { public function sendNotification() { return Larafirebase::withTitle('Hello World') ->withBody('I have something new to share with you!') ->withImage('https://firebase.google.com/images/social.png') ->withAdditionalData([ 'name' => 'wrench', 'mass' => '1.3kg', 'count' => '3' ]) ->withToken('TOKEN_HERE') // You can use also withTopic ->sendNotification(); // Or return Larafirebase::fromRaw([ // https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages "name" => "string", "data" => [ "string" => "string", ], "notification" => [ "object" => "(Notification)" ], "android" => [ "object" => "(AndroidConfig)" ], "webpush" => [ "object" => "(WebpushConfig)", ], "apns" => [ "object" => "(ApnsConfig)" ], "fcm_options" => [ "object" => "(FcmOptions)" ], "token" => "string", "topic" => "string", "condition" => "string" ])->sendNotification(); } }
Example usage in Notification class:
use Illuminate\Notifications\Notification; use CodeCoveVienna\Larafirebase\Messages\FirebaseMessage; class SendBirthdayReminder extends Notification { /** * Get the notification's delivery channels. */ public function via($notifiable) { return ['firebase']; } /** * Get the firebase representation of the notification. */ public function toFirebase($notifiable) { return (new FirebaseMessage) ->withTitle('Hey, ', $notifiable->first_name) ->withBody('Happy Birthday!') ->withToken('TOKEN_HERE') ->asNotification(); } }
Tips
- You can use
larafirebase()helper instead of Facade.
codecovevienna/larafirebase 适用场景与选型建议
codecovevienna/larafirebase 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 131 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 03 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 codecovevienna/larafirebase 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 codecovevienna/larafirebase 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 131
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 19
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-03-30
