PHPackages                             cjpanilag/simple-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. cjpanilag/simple-notifications

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

cjpanilag/simple-notifications
==============================

Simplified notifications for AWS SNS, FCM Push Notifications, emails, and more.

1.0.1(3y ago)0581MITPHPPHP ^8.0

Since Mar 28Pushed 2y ago1 watchersCompare

[ Source](https://github.com/cjpanilag/simple-notifications)[ Packagist](https://packagist.org/packages/cjpanilag/simple-notifications)[ Docs](https://github.com/cjpanilag/simple-notifications)[ RSS](/packages/cjpanilag-simple-notifications/feed)WikiDiscussions develop Synced today

READMEChangelogDependencies (9)Versions (4)Used By (0)

Simple Notifications for Laravel 8|9|10
=======================================

[](#simple-notifications-for-laravel-8910)

[![Latest Version on Packagist](https://camo.githubusercontent.com/665790e57d59e9d6b2c97747db6a33b5f69314b4d2d5cf39ff0662c699c1c06a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f636a70616e696c61672f73696d706c652d6e6f74696669636174696f6e732e737667)](https://packagist.org/packages/cjpanilag/simple-notifications)[![Total Downloads](https://camo.githubusercontent.com/b62fa33d8b903659aa13c262e1e1e9ed58bfb1119fb1c1641bdd3527acdd4eab/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f636a70616e696c61672f73696d706c652d6e6f74696669636174696f6e732e737667)](https://packagist.org/packages/cjpanilag/simple-notifications)[![GitHub Repo stars](https://camo.githubusercontent.com/96da43c088f9d133c7343b00dbd7a137c63d3244b4b93e88171a5eac16674e5f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f636a70616e696c61672f73696d706c652d6e6f74696669636174696f6e73)](https://github.com/cjpanilag/simple-notifications)[![Discord](https://camo.githubusercontent.com/bd46299a29c3cae288e34846117d44d0cb853da2dad0c376fd8bca3fc269f3b6/68747470733a2f2f696d672e736869656c64732e696f2f646973636f72642f313134333734343631393935363430343239353f636f6c6f723d386339656666266c6162656c3d446973636f7264266c6f676f3d646973636f7264)](https://discord.gg/MBxxAkQAxx)[![Twitter Follow](https://camo.githubusercontent.com/e776839a6ca38d4fca737d481d31712ee1207d00f1ad41144d429cf7ea9aa936/68747470733a2f2f696d672e736869656c64732e696f2f747769747465722f666f6c6c6f772f6361726c6a656666726965)](https://twitter.com/carljeffrie)

Simplified notifications for AWS SNS, FCM Push Notifications, emails, and more.

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

[](#installation)

Via Composer

```
$ composer require cjpanilag/simple-notifications --with-all-dependencies
$ php artisan migrate
```

After migration, `simple-notification` will generate two (2) tables namely `fcm_tokens` &amp; `simple_devices`. Make sure to remove any conflicting table or attribute in your root project.

Usage
-----

[](#usage)

### AWS SNS

[](#aws-sns)

**User Model Configuration**

```
use Cjpanilag\SimpleNotifications\Traits\HasSnsNotifiableTrait;

class User extends Authenticatable
{

    use HasApiTokens, HasFactory, HasSnsNotifiableTrait;

    /**
     * Overridden method (optional)
     * By default, `SnsNoticiableTrait` will look
     * for the specific attribute in your model:
     *       `phone`,
     *       `phone_number`,
     *       `full_phone`
     *
     * @override
     * @param $notification
     * @return string|null
     */
    public function routeNotificationForSns($notification): string|null
    {
        // model attribute
        return $this->specific_mobile_number_attribute;
    }
}
```

*Note*: In order to let your `Notification` know which phone you are sending to, the channel will look for the `phone`, `phone_number` or `full_phone` attribute of the `Notifiable` model.

**Sending SMS to user**

```
// Sending SMS to a User model...
$user = User::first();

simpleNotifications()->sns()
            ->user($user)
            ->content('Message here...')
            ->execute();

// Sending SMS to a specific phone...
simpleNotifications()->sns()
            ->mobile('+639123456789')
            ->content('Message here...')
            ->execute();
```

**Sending SMS using content callable**

```
// Sending SMS to a User model...
$user = User::first();

simpleNotifications()->sns()
            ->user($user)
            ->content(fn($user) => "Welcome $user->name") // passing notifiable
            ->execute();

// Sending SMS to a specific phone...
simpleNotifications()->sns()
            ->mobile('+639123456789')
            ->content(fn($user) => "Welcome $user->name") // passing notifiable
            ->execute();
```

**Sending SMS using `SnsMessage` as content**

```
// Sending SMS to a User model...
$user = User::first();

simpleNotifications()->sns()->user($user)->content(function ($user) {
    $snsMessage = new SnsMessage('message here...');

    $snsMessage->sender('FIN-PAY');
    $snsMessage->transactional(true);

    return $snsMessage;
})->execute();

// Sending SMS to a specific phone...
simpleNotifications()->sns()->mobile('+639123456789')->content(function ($user) {
    $snsMessage = new SnsMessage('message here...');

    $snsMessage->sender('FIN-PAY');
    $snsMessage->transactional(true);

    return $snsMessage;
})->execute();
```

Available Methods

methodparameterreturn typedescriptionuser`Model``static`assigning user.content`SnsMessage` `string` `callable``static`can be message or a callable function.mobile`string``static`replacement for `user` methods.executenone`void`will execute the sending.*Note*: `user` or `mobile` method should not be used *at the same time*.

Example:

```
simpleNotifications()->sns()
            ->user($user)               // User already have ...
            ->mobile('+63923456789')    // Will conflict with User mobile number attribute...
            ->content('Message here...')
            ->execute();
```

### SES MAIL

[](#ses-mail)

**User Model Configuration**

```
use Cjpanilag\SimpleNotifications\Traits\HasMailNotifiableTrait;

class Model extends Authenticatable
{
    use HasApiTokens, HasFactory, HasMailNotifiableTrait;

    /**
     * @param $notification
     * @return array|string|null
     */
    public function routeNotificationForMail($notification): array|string|null
    {
        // Define a specific
        return $this->email_address;
    }
}
```

*Note*: By default, `Notification` will send email to User's `email` attribute.

**Sending Mail to user**

```
// Sending mail to a User model...
$user = User::first();

simpleNotifications()->mail()
    ->user($user)
    ->subject('Test Subject 123')
    ->body('test body')
    ->footer('test footer')
    ->actionMessage('PUSH ME!')
    ->actionUrl('http://localhost')
    ->execute();

// Sending mail to a specific email address...
simpleNotifications()->mail()
    ->emailAddress('testemail123@gmail.com')
    ->subject('Test Subject 123')
    ->body('test body')
    ->footer('test footer')
    ->actionMessage('PUSH ME!')
    ->actionUrl('http://localhost')
    ->execute();
```

**Sending Mail using `MailMessage` as content**

```
// Sending mail to a User model...
$user = User::first();

simpleNotifications()->mail()->user($user)->content(function ($user) {
    $mailMessage = new MailMessage();
    $subject = 'test subject 2';

    if ($user) {
        $mailMessage->subject($subject);
    }

    $mailMessage->line('this is a best body number 2')
        ->action('PUSH ME!', 'https://test.com')
        ->line('this is a test footer 2');

    return $mailMessage;
})->execute();

// Sending mail to a specific email address...
```php
simpleNotifications()->mail()->emailAddress('testemail123@gmail.com')->content(function ($user) {
    $mailMessage = new MailMessage();
    $subject = 'test subject 2';

    if ($user) {
        $mailMessage->subject($subject);
    }

    $mailMessage->line('this is a best body number 2')
        ->action('PUSH ME!', 'https://test.com')
        ->line('this is a test footer 2');

    return $mailMessage;
})->execute();
```

**Sending Mail using `MailMessage` with customized `view` as content**

```
// Sending mail to a specific email address...
simpleNotifications()->mail()->emailAddress('testemail123@gmail.com')->content(function ($user) {
    $mailMessage = new MailMessage();

    $mailMessage->view('view.template');

    return $mailMessage;
})->execute();
```

Available Methods

methodparameterreturn typedescriptionuser`Model``static`notifiable.subject`string``static`email subject.title`string``static`email title.footer`string``static`email footer.actionMessage`string``static`action message.actionUrl`string``static`action URL.emailAddress`string``static`replacement for `user` methods.executenone`static`execute notification.*Note*: `user` or `emailAddress` method should not be used *at the same time*.

Example:

```
$user = User::first();

simpleNotifications()->mail()
    ->user($user)                               // user has email attribute
    ->emailAddress('testemail123@gmail.com')    // conflict with email attribute
    ->subject('Test Subject 123')
    ->body('test body')
    ->footer('test footer')
    ->actionMessage('PUSH ME!')
    ->actionUrl('http://localhost')
    ->execute();
```

### FCM Notification

[](#fcm-notification)

Make sure that you already run `artisan migrate` after installing this package. FCM will use the `fcm_tokens` table and `simple_devices` table.

`simple_devices` table stores users' devices. Each device can have multiple FCM tokens. `fcm_tokens` table stores the devices' FCM tokens.

**Simple Device API**

A route will be provided by this package. Check your project level `routes/api.php` for possible conflicts.

```
POST /api/device

```

body

keydescriptiondevice\_id`required` `unique`unique\_id`required`brandnullabletypenullablenamenullablemanufacturernullablemodelnullablesystem\_namenullablesystem\_versionnullableversionnullableactivenullable**FCM Token API**

A route will be provided by this package. Check your project level `routes/api.php` for possible conflicts.

```
POST /api/fcm-token

```

keydescriptiondevice\_uuid`required`token`required`**Sending FCM Notification to user**

```
$user = User::first();

simpleNotifications()
    ->fcm()
    ->user($user)
    ->data([])
    ->title('Welcome Test')
    ->body('just test')
    ->execute();
```

**Sending FCM Notification using FCM Token**

```
simpleNotifications()
    ->fcm()
    ->token($token)
    ->data([])
    ->title('Welcome Test')
    ->body('just test')
    ->execute();
```

Available Methods

methodparameterdescriptionuser`Model`notifiabledata`array`notification datatitle`string`notification titlebody`string`notification messageexecutenoneexecute sendChange log
----------

[](#change-log)

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

Testing
-------

[](#testing)

```
$ composer test
```

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

[](#contributing)

Please see [contributing.md](contributing.md) for details and a todolist.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Carl Jeffrie Panilag](https://github.com/cjpanilag)
- [All Contributors](../../contributors)

License
-------

[](#license)

MIT. Please see the [license file](license.md) for more information.

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~45 days

Total

2

Last Release

1146d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/911ad82e6090c095baeb232acbf7132fb456276696cf8a3cd504b3623dea982c?d=identicon)[cjpanilag](/maintainers/cjpanilag)

---

Top Contributors

[![luchtech](https://avatars.githubusercontent.com/u/26067874?v=4)](https://github.com/luchtech "luchtech (1 commits)")

---

Tags

laravelSimpleNotifications

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/cjpanilag-simple-notifications/health.svg)

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

###  Alternatives

[propaganistas/laravel-disposable-email

Disposable email validator

6023.0M7](/packages/propaganistas-laravel-disposable-email)[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[erag/laravel-disposable-email

A Laravel package to detect and block disposable email addresses.

254168.5k](/packages/erag-laravel-disposable-email)[fleetbase/core-api

Core Framework and Resources for Fleetbase API

1235.9k20](/packages/fleetbase-core-api)

PHPackages © 2026

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