Download the PHP package amdadulhaq/fcm-laravel without Composer
On this page you can find all versions of the php package amdadulhaq/fcm-laravel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download amdadulhaq/fcm-laravel
More information about amdadulhaq/fcm-laravel
Files in amdadulhaq/fcm-laravel
Package fcm-laravel
Short Description A simple, lightweight, fast Firebase Cloud Messaging (FCM) notification channel for Laravel.
License MIT
Homepage https://github.com/amdad121/fcm-laravel
Informations about the package fcm-laravel
FCM (Firebase Cloud Messaging) for Laravel
A simple, lightweight, fast Firebase Cloud Messaging (FCM) notification channel for Laravel. No Firebase Admin SDK, no bloat — just push notifications, configurable, with a fake for testing.
Requirements
- PHP 8.2, 8.3, 8.4, or 8.5
- Laravel 11, 12, or 13
Installation
The service provider is auto-discovered. Publish the config file:
Configuration
Set FIREBASE_CREDENTIALS to the path of your Firebase service account JSON file (download it from Project settings → Service accounts in the Firebase console). The Firebase project ID is read from that file automatically — nothing else is required to start sending.
See config/fcm.php for every option:
| Option | Env | Default | Purpose |
|---|---|---|---|
credentials |
FIREBASE_CREDENTIALS |
— | Path to the service account JSON. Absolute or relative to the app base path. |
http.timeout |
FCM_HTTP_TIMEOUT |
10 |
HTTP timeout (seconds) for the send request. |
android.priority |
FCM_ANDROID_PRIORITY |
normal |
Default for every message's android payload. Set to null to omit. A notification can override it for itself alone — see Notifications. |
android.channel_id |
FCM_ANDROID_CHANNEL_ID |
default_channel |
Android notification channel ID. Set to null to omit. A notification can override it for itself alone too. |
apns.priority |
FCM_APNS_PRIORITY |
— | Sets apns.headers.apns-priority (5 or 10). Omitted from the payload unless set. |
debug |
FCM_DEBUG |
APP_DEBUG |
Logs skipped sends, rejected tokens, and delivery failures. Independent of the host app's app.debug. |
log_channel |
FCM_LOG_CHANNEL |
— | Log channel debug messages are written to. Defaults to the app's default channel. |
dry_run |
FCM_DRY_RUN |
false |
Builds and logs the message but never calls the FCM API; sendToToken() returns true as if it succeeded. Handy for local/staging. |
Notifications
Implement toFcm() on any notification, have it implement HasFcmPayload, and route it through the fcm channel:
Return an optional priority ('high' or 'normal') and/or channel_id to override config('fcm.android.priority') and config('fcm.android.channel_id') for that one notification, leaving every other notification on the configured default:
channel_id only changes which Android notification channel the OS delivers into — the app must still create that channel itself (flutter_local_notifications's createNotificationChannel, or NotificationManager.createNotificationChannel on native Android) with whatever importance/sound it wants; this package only stamps the outgoing message with the channel's ID.
The channel resolves device tokens via Laravel's standard routeNotificationFor('fcm', $notification) convention. Add a routeNotificationForFcm() method to the notifiable:
Sends to a token that FCM reports as unregistered or invalid throw internally and are reported through the AmdadulHaq\Fcm\Events\FcmTokenRejected event instead of stopping delivery to the notifiable's other tokens — listen for it to prune the dead token from wherever you store them:
Sending directly
For a one-off send outside the notification system, use FcmService directly:
Testing
Use FcmService::fake() to swap the real service with an in-memory fake and assert on what would have been sent, without dispatching anything or hitting the network:
$fake->rejectToken($token) makes sends to that token throw FcmUnregisteredTokenException (without a real FCM error response), so you can exercise the FcmTokenRejected pruning path in tests.
Running the package's own test suite
License
MIT. See LICENSE.md.
All versions of fcm-laravel with dependencies
google/auth Version ^1.53
illuminate/notifications Version ^11.0|^12.0|^13.0
illuminate/support Version ^11.0|^12.0|^13.0