PHPackages                             akhelij/larabase-notification - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Mail &amp; Notifications](/categories/mail)
4. /
5. akhelij/larabase-notification

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

akhelij/larabase-notification
=============================

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.

v2.2.0(1mo ago)563MITPHPPHP ^8.1CI failing

Since Oct 20Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/akhelij/larabase-notification)[ Packagist](https://packagist.org/packages/akhelij/larabase-notification)[ Docs](https://github.com/akhelij/larabase-notification)[ RSS](/packages/akhelij-larabase-notification/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (14)Versions (8)Used By (0)

LarabaseNotification
====================

[](#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
--------

[](#features)

- **Laravel Notification Channel**: Uses Laravel's native notification system with a custom `larabase` channel
- **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
------------

[](#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
------------

[](#installation)

```
composer require akhelij/larabase-notification
```

Configuration
-------------

[](#configuration)

### 1. Publish the Configuration File

[](#1-publish-the-configuration-file)

```
php artisan vendor:publish --provider="Akhelij\LarabaseNotification\LarabaseNotificationServiceProvider" --tag="config"
```

### 2. Set Environment Variables

[](#2-set-environment-variables)

Add the following to your `.env` file:

```
FIREBASE_PROJECT_ID=your-firebase-project-id
FIREBASE_SERVICE_ACCOUNT_FILE=app/firebase_credentials.json
```

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

[](#3-configuration-options)

The published `config/larabase-notification.php` supports these settings:

KeyEnv VariableDefaultDescription`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 batchUsage
-----

[](#usage)

### Basic Notification

[](#basic-notification)

```
