Download the PHP package akhelij/larabase-notification without Composer
On this page you can find all versions of the php package akhelij/larabase-notification. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download akhelij/larabase-notification
More information about akhelij/larabase-notification
Files in akhelij/larabase-notification
Package larabase-notification
Short Description A lightweight Laravel package for sending push notifications via Firebase Cloud Messaging (FCM) HTTP v1 API. Send device-specific notifications to Android, iOS, and web applications with minimal setup, concurrent delivery, and automatic retry.
License MIT
Homepage https://github.com/akhelij/larabase-notification
Informations about the package larabase-notification
LarabaseNotification
A lightweight Laravel package for sending Firebase Cloud Messaging (FCM) push notifications via the HTTP v1 API. Minimal dependencies, concurrent delivery, automatic retry, and full Laravel notification system integration.
Features
- Laravel Notification Channel: Uses Laravel's native notification system with a custom
larabasechannel - Firebase HTTP v1 API: Uses the current FCM standard with OAuth 2.0 authentication
- Concurrent Delivery: Sends to multiple devices in parallel via
Http::pool() - OAuth Token Caching: Caches access tokens to avoid redundant auth requests
- Automatic Retry: Configurable retry with backoff for transient failures (429, 500, 503)
- NotificationFailed Events: Dispatches Laravel events for failed deliveries (e.g., stale token cleanup)
- Send Reports: Structured results with success/failure counts and unregistered token detection
- Image Support: Native FCM notification images
- Platform Config: Customizable Android, iOS (APNs), and Webpush settings
- Payload Validation: Validates payload size against FCM limits before sending
- Queue Support: Works with Laravel's queue system out of the box
- Multi-Tenant: Inject custom Firebase clients per notification for different projects
Requirements
- PHP: 8.1 or higher
- Laravel: 10.x, 11.x, or 12.x
- Firebase Project: A Firebase project with a service account JSON file
Installation
Configuration
1. Publish the Configuration File
2. Set Environment Variables
Add the following to your .env file:
The service account file path is relative to storage_path(). Ensure the JSON file is kept secure and not committed to version control.
3. Configuration Options
The published config/larabase-notification.php supports these settings:
| Key | Env Variable | Default | Description |
|---|---|---|---|
project_id |
FIREBASE_PROJECT_ID |
— | Your Firebase project ID |
service_account_file |
FIREBASE_SERVICE_ACCOUNT_FILE |
app/firebase_credentials.json |
Path to service account JSON (relative to storage/) |
retry.attempts |
LARABASE_RETRY_ATTEMPTS |
3 |
Number of retry attempts on transient failures |
retry.delay |
LARABASE_RETRY_DELAY |
100 |
Delay between retries in milliseconds |
timeout |
LARABASE_TIMEOUT |
30 |
HTTP request timeout in seconds |
chunk_size |
LARABASE_CHUNK_SIZE |
500 |
Max tokens per concurrent batch |
Usage
Basic Notification
With Image
Platform-Specific Configuration
Or pass full platform config arrays directly:
Handling Failed Notifications
Register an event listener to handle failed deliveries (e.g., removing stale tokens):
Using Send Reports
The send() method returns a LarabaseSendReport:
Multi-Tenant (Custom Firebase Project)
For applications using multiple Firebase projects:
Using the Facade
Upgrading from v1.x
Breaking Changes
- PHP 8.1+ required (was 7.4+)
- Laravel 10+ required (was 7+)
Behavioral Changes (Non-Breaking)
- Token filtering:
asNotification()now automatically filters outnull, empty, and non-string values, and deduplicates tokens. Previously these would cause errors or wasted API calls. - Data validation:
withAdditionalData()now casts scalar values to strings and convertsnullto empty string. Non-scalar values (arrays, objects) throwInvalidArgumentException. - OAuth caching: Access tokens are now cached for ~58 minutes instead of fetching a new one per send.
- Concurrent sending: Multiple tokens are sent in parallel instead of sequentially.
- Events:
NotificationFailedevents are now dispatched for each failed token.
Testing
License
This package is open-sourced software licensed under the MIT license.
Contact
For questions or support, please open an issue on the GitHub repository.
All versions of larabase-notification with dependencies
google/auth Version ^1.42
illuminate/http Version ^10.0|^11.0|^12.0|^13.0
illuminate/notifications Version ^10.0|^11.0|^12.0|^13.0
illuminate/support Version ^10.0|^11.0|^12.0|^13.0