PHPackages                             marcioelias/laravel-notifications - 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. marcioelias/laravel-notifications

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

marcioelias/laravel-notifications
=================================

This package handle notifictation like push notifications, sms, etc. The focus is using AWS Services.

v1.8.3(5mo ago)031[1 PRs](https://github.com/marcioelias/laravel-notifications/pulls)MITPHPPHP ^8.3CI passing

Since Dec 23Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/marcioelias/laravel-notifications)[ Packagist](https://packagist.org/packages/marcioelias/laravel-notifications)[ Docs](https://github.com/marcioelias/laravel-notifications)[ GitHub Sponsors](https://github.com/MarcioElias)[ RSS](/packages/marcioelias-laravel-notifications/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (10)Versions (25)Used By (0)

Send notifications with AWS SNS made easy.
==========================================

[](#send-notifications-with-aws-sns-made-easy)

[![Latest Version on Packagist](https://camo.githubusercontent.com/bb72e673a74f49ab9be9d04826f601b8a5c009e56fecdbc3bc843d64b8eaae22/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d617263696f656c6961732f6c61726176656c2d6e6f74696669636174696f6e732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/marcioelias/laravel-notifications)[![Tests](https://github.com/marcioelias/laravel-notifications/workflows/run-tests/badge.svg)](https://github.com/marcioelias/laravel-notifications/workflows/run-tests/badge.svg)[![Total Downloads](https://camo.githubusercontent.com/67dc680559ec20854694bac8b547e6b4be818aee177ffcfeb6ae4418ff386c87/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d617263696f656c6961732f6c61726176656c2d6e6f74696669636174696f6e732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/marcioelias/laravel-notifications)

The goal of this package is turn very easy the process of sending notifications using AWS SNS. It provides a facade to send notifications, and an API to be used to interact with the notifications (push notifications only).

Here are the endpoints available:

```
# used to create a endpoint ARN on AWS SNS Application
# stores the ARN at users table on column device_token)

POST /api/device-token
```

```
# used to get all notifications paginated
# see config to customize per page number and FormResource class

GET /api/notifications
```

```
# mark a notification as readed

PUT /api/notification/{notification}/read
```

```
# mark a notification as unreaded

PUT /api/notification/{notification}/unread
```

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require marcioelias/laravel-notifications
```

Publishing Resources
--------------------

[](#publishing-resources)

To see all available publishable resources, run:

```
php artisan vendor:publish --provider="MarcioElias\LaravelNotifications\LaravelNotificationsServiceProvider"
```

Or publish specific resources using tags:

**Publish the migrations:**

```
php artisan vendor:publish --tag="laravel-notifications-migrations"
```

**Publish the config file** (Optional, just required if you need to config some customizations):

```
php artisan vendor:publish --tag="laravel-notifications-config"
```

**Publish translations:**

```
php artisan vendor:publish --tag="laravel-notifications-translations"
```

**Publish routes:**

```
php artisan vendor:publish --tag="laravel-notifications-routes"
```

**Publish custom fields migration:**

```
php artisan vendor:publish --tag="laravel-notifications-custom-fields-migration"
```

This is the contents of the published config file:

```
return [
     /*
    |--------------------------------------------------------------------------
    | Supported Push Notification Providers
    |--------------------------------------------------------------------------
    |
    | Currently this package can send push notification with AWS SNS Service.
    | Please not that using AWS services, this package will be using by default
    | the default configurations for AWS on .env file.
    |
    | Here are the keys that can be used to configure the service provider:
    |  - aws_sns
    |
    */
    'push_service_provider' => env('PUSH_SERVICE_PROVIDER', 'aws_sns'),

    /*
    |--------------------------------------------------------------------------
    | AWS SNS Application ARN
    |--------------------------------------------------------------------------
    |
    | The ARN of the application that will be used to send push notifications.
    | This ARN is used to create a platform endpoint.
    |
    */
    'aws_sns_application_arn' => env('AWS_SNS_APPLICATION_ARN', null),

    /*
    |--------------------------------------------------------------------------
    | Tables with alertable trait on his models
    |--------------------------------------------------------------------------
    |
    | Will be executed a migration to create device_token column on each table
    | listed here.
    |
    */
    'alertable_tables' => [
        'users',
    ],

    /*
    |--------------------------------------------------------------------------
    | API Endpoints configuration
    |--------------------------------------------------------------------------
    |
    | Allow the configuration of the API endpoints for the notifications
    | resources.
    |
    */
    'api' => [
        'notification_resource' =>  \MarcioElias\LaravelNotifications\Resources\NotificationResource::class,
        'pagination' => 20,
    ]
];
```

After config the package, run the migrations

```
php artisan migrate
```

Usage
-----

[](#usage)

Sending a push notification

```
    use MarcioElias\LaravelNotifications\LaravelNotifications;

    ...

    public function myFunction(): void
    {
        //my own code
        ...
        LaravelNotifications::sendPush(
            title: 'my title',
            body: 'Hello, this is a push notification'
        )
    }
```

You can add some custom object to the push notification.

```
    use MarcioElias\LaravelNotifications\LaravelNotifications;

    ...

    public function myFunction(): void
    {
        //my own code
        ...
        LaravelNotifications::sendPush(
            title: 'my title',
            body: 'Hello, this is a push notification',
            data: [
                'id' => Auth::id(),
                'name' => Auth::user()->name
            ]
        )
    }
```

### Custom Fields in Notifications Table

[](#custom-fields-in-notifications-table)

You can add custom fields to the `notifications` table to store additional data with each notification.

**Step 1: Publish the custom fields migration**

```
php artisan vendor:publish --tag="laravel-notifications-custom-fields-migration"
```

The migration will be published to:

- **Default**: `database/migrations/`
- **Tenancy for Laravel**: Automatically detected and published to `database/tenant` or `Database/Tenant`
- **Custom path**: Configure in `config/notifications.php` or via `NOTIFICATIONS_MIGRATIONS_PATH` env variable

**Configuring custom migrations directory:**

If you're using Tenancy for Laravel, the package will automatically detect it. You can also manually configure the path:

**Option 1: Via config file** (`config/notifications.php`):

```
'migrations_path' => 'database/tenant', // or 'Database/Tenant'
```

**Option 2: Via environment variable** (`.env`):

```
NOTIFICATIONS_MIGRATIONS_PATH=database/tenant
```

**Step 2: Edit the migration file**

Open the published migration file and add your custom fields:

```
public function up()
{
    Schema::table('notifications', function (Blueprint $table) {
        $table->string('category')->nullable();
        $table->integer('priority')->default(0);
        $table->foreignId('related_id')->nullable();
        // Add your custom fields here
    });
}
```

**Step 3: Run the migration**

```
php artisan migrate
```

**Step 4: Use custom fields when sending notifications**

```
use MarcioElias\LaravelNotifications\LaravelNotifications;

LaravelNotifications::sendPush(
    to: $user,
    title: 'New Order',
    body: 'You have a new order',
    data: ['order_id' => 123],
    customFields: [
        'category' => 'order',
        'priority' => 5,
        'related_id' => 123
    ]
);
```

The custom fields will be saved in the `notifications` table along with the standard notification data.

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Marcio Elias](https://github.com/marcioelias)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance82

Actively maintained with recent releases

Popularity7

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 85.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~15 days

Recently: every ~81 days

Total

23

Last Release

162d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/293153cf1a05dc29fe1c7e1795d7ad0c45b32723bf4d6ef1e0f1ab5a0bb2fa24?d=identicon)[marcioelias](/maintainers/marcioelias)

---

Top Contributors

[![marcioelias](https://avatars.githubusercontent.com/u/2084051?v=4)](https://github.com/marcioelias "marcioelias (69 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (7 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (5 commits)")

---

Tags

laravellaravel-notificationsMarcioElias

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/marcioelias-laravel-notifications/health.svg)

```
[![Health](https://phpackages.com/badges/marcioelias-laravel-notifications/health.svg)](https://phpackages.com/packages/marcioelias-laravel-notifications)
```

###  Alternatives

[vormkracht10/laravel-mails

Laravel Mails can collect everything you might want to track about the mails that has been sent by your Laravel app.

24149.7k](/packages/vormkracht10-laravel-mails)[xammie/mailbook

Laravel Mail Explorer

482458.3k1](/packages/xammie-mailbook)[spatie/laravel-notification-log

Log notifications sent by your Laravel app

207902.8k](/packages/spatie-laravel-notification-log)[wnx/laravel-sends

Keep track of outgoing emails in your Laravel application.

200427.3k](/packages/wnx-laravel-sends)[spatie/laravel-discord-alerts

Send a message to Discord

151408.0k](/packages/spatie-laravel-discord-alerts)[backstage/laravel-mails

Laravel Mails can collect everything you might want to track about the mails that has been sent by your Laravel app.

24157.5k5](/packages/backstage-laravel-mails)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
