PHPackages                             singlephon/hotification - 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. singlephon/hotification

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

singlephon/hotification
=======================

Easy configurable event-based Laravel notification package.

v2.0.1(8mo ago)01.1kMITPHPPHP ^8.2

Since Aug 29Pushed 8mo ago1 watchersCompare

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

READMEChangelog (5)Dependencies (7)Versions (6)Used By (0)

Hotification
============

[](#hotification)

[![Latest Version on Packagist](https://camo.githubusercontent.com/83a409b93fb64f2add2faa5dbfba769474eda65585f4b9f2678e1bd8447628aa/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73696e676c6570686f6e2f686f74696669636174696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/singlephon/hotification)[![Total Downloads](https://camo.githubusercontent.com/5e8b2fc8ed05ebcd5b974a337734c5d04e05ee4c584bfe71a1451bd864882e0d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73696e676c6570686f6e2f686f74696669636174696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/singlephon/hotification)

`Hotification` is a powerful and flexible package for managing notifications in Laravel applications. It provides a convenient API for sending notifications, adding observers, and handling events.

### Key Features

[](#key-features)

- Easy configuration through a single file: `config/hotification.php`.
- Extensibility with custom sender and observer classes.
- Instant sending of notifications to the database.
- Dynamic addition of observers for models.
- Execute any logic upon model changes.

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

[](#installation)

1. Install via Composer:

```
composer require singlephon/hotification
```

```
php artisan hotification:install
```

2. Register the service provider and alias:

Add the following to `config/app.php`:

```
'providers' => [
    # ...
    Singlephon\Hotification\HotificationServiceProvider::class,
],
'aliases' => [
    # ...
    'Hotification' => \Singlephon\Hotification\Hotification::class,
]
```

Quick Start
-----------

[](#quick-start)

### Sending Notifications

[](#sending-notifications)

Use the `HotificationSender` class for instant sending of notifications to the database:

```
use App\Models\User;

(new Hotification())
    ->notify(User::find(1))
    ->icon('exclamation-triangle')
    ->title('Important notification...')
    ->description('Some description...')
    ->url('/app/friends/invitations')
    ->actionable()
    ->send();
```

This will add a record to the `notifications` table.

### Automating Notification Sending with Observers

[](#automating-notification-sending-with-observers)

Define observers and scheduled notifications directly in `App\Hotification\Models` and `App\Hotification\Schedules` classes.

#### Example: Configuring Observers

[](#example-configuring-observers)

The example below demonstrates how to define observers for models in the `App\Hotification\Models` class:

```
namespace App\Hotification;

use Hotification;

class Models
{
    public function observers(): array
    {
        return [
            # ...
        ];
    }
}
```

### Using Observers for Models

[](#using-observers-for-models)

The example below shows how to configure observers for the `Post` and `User` models using hooks like `onCreated`, `onUpdated`, and `onDeleted`:

```
return [
    \App\Models\Post::class => [
        # Send a notification when a new post is created
        'onCreated' => [
            \App\Notifications\PostCreatedNotification::class, # Should extend Singlephon\Hotification\Notifications\AbstractHotification
            function (Post $post) {
                # Callback to execute custom logic when a post is created
                # For example, sending a Push notification, logging, or modifying other properties
            },
        ],
        # Send a notification when a post is updated
        'onUpdated' => [
            \App\Notifications\PostUpdatedNotification::class,
        ]
    ],

    \App\Models\User::class => [
        'onCreated' => [
            function (User $user) {
                # Callback for executing logic when a new user is created
                # For example, sending a welcome message or logging activity
                (new Hotification())
                    ->notify($user)
                    ->icon('check-badge')
                    ->title('Welcome ' . $user->name)
                    ->description('Please continue registration form...')
                    ->url('/app/registration/continue')
                    ->actionable()
                    ->send();
            },
        ],
        # Send a notification when a user is deleted
        'onDeleted' => [
            \App\Notifications\ByeByeNotification::class,
            function (User $user) {
                # Callback for executing logic when a user is deleted
                # For example, sending a notification to the administrator
            }
        ]
    ]

]
```

⚠️ Note: Notification classes must extend the `Singlephon\Hotification\Notifications\AbstractHotification` class.

### Advantages of Using Observers

[](#advantages-of-using-observers)

- **Centralized Logic**: Allows all logic related to model events to be concentrated in one place.
- **Easy Management**: Easily add or change behavior on events by simply updating observer configuration.
- **Extensibility**: Use both built-in notifications and custom callbacks, providing flexibility in event handling.

### Recommendations

[](#recommendations)

- **Use hooks only when necessary** to avoid unnecessary complexity in logic.
- **Avoid overloading a single hook** with too many actions to maintain performance and ease of debugging.
- For complex logic, consider moving it into separate services or classes to maintain clean and readable code.

#### Using Scheduled Notifications

[](#using-scheduled-notifications)

Scheduled notifications are defined in the `App\Hotification\Schedules` class. You can specify tasks to be performed on a schedule, such as sending notifications or executing custom logic.

#### Example: Configuring Scheduled Notifications

[](#example-configuring-scheduled-notifications)

```
namespace App\Hotification;

use Notification;

class Schedules
{
    public function setup(): array
    {
        return [
            'weekly_report' => function (Schedule $schedule) {
                $schedule->call(function () {
                    (new Hotification())
                        ->notify(User::all())
                        ->icon('check-badge')
                        ->title('Welcome ' . $user->name)
                        ->description('Please continue registration form...')
                        ->url('/app/registration/continue')
                        ->actionable()
                        ->send();
                })->everyWeek(); # Runs every week
            },
            'daily_report' => [
                'events' => [
                    \App\Notifications\DailyReportNotification::class, # Sending a notification
                    function () {
                        # Logic for executing a custom action
                        # For example, generating a report and sending it via email
                    },
                ],
                'schedule' => '0 0 * * *', # Every day at midnight
            ]
        ]
    }
}
```

⚠️ Note: Notification classes must extend the `Singlephon\Hotification\Notifications\AbstractHotification` class.

### Advantages of Using `scheduled_notifications`

[](#advantages-of-using-scheduled_notifications)

- **Flexibility**: Combine notifications and custom callbacks in a single task.
- **Convenience**: Easily add and modify tasks using configuration files.
- **Automation**: Automatically perform routine tasks like sending reports or performing regular updates.

### Recommendations

[](#recommendations-1)

- **Test your tasks**: Ensure schedules are set correctly and tasks run at the intended times.
- **Avoid overly frequent tasks**: Schedule tasks at reasonable intervals to avoid overloading the system.
- **Use callbacks for complex logic**: If a task requires complex processing, move that logic into callbacks or separate services.

### Dynamic Addition of Observers at Runtime

[](#dynamic-addition-of-observers-at-runtime)

One of the key aspects of using Hotification is the ability to dynamically add observers (handlers) to models directly at runtime, not only through configuration files. This provides high flexibility and allows for programmatic management of notification behavior depending on context or business logic.

### Example Code

[](#example-code)

Consider the following example, which dynamically adds an observer for the `User` model:

```
(new Hotification())
    ->manager()
    ->add(User::class,
        onUpdated: [function (User $user) {}],
        onCreated: [function (User $user) {}],
        onDeleted: [function (User $user) {}]
    );
```

### Changelog

[](#changelog)

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

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

[](#contributing)

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

### Security

[](#security)

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

Credits
-------

[](#credits)

- [Rakhat Bakytzhanov](https://github.com/singlephon)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance59

Moderate activity, may be stable

Popularity17

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity56

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 ~90 days

Total

5

Last Release

265d ago

Major Versions

v1.0.2 → v2.0.02024-12-18

### Community

Maintainers

![](https://www.gravatar.com/avatar/9bf20d8fb33ebdd3ed4db311b4e66d81f7065bef57c577fa523ca62f7133ee62?d=identicon)[singlephon](/maintainers/singlephon)

---

Top Contributors

[![singlephon](https://avatars.githubusercontent.com/u/107846206?v=4)](https://github.com/singlephon "singlephon (7 commits)")

---

Tags

notificationsinglephonhotification

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/singlephon-hotification/health.svg)

```
[![Health](https://phpackages.com/badges/singlephon-hotification/health.svg)](https://phpackages.com/packages/singlephon-hotification)
```

###  Alternatives

[laravel/cashier

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.

2.5k25.9M107](/packages/laravel-cashier)[laravel-notification-channels/telegram

Telegram Notifications Channel for Laravel

1.1k3.4M35](/packages/laravel-notification-channels-telegram)[laravel-notification-channels/discord

Laravel notification driver for Discord.

2371.3M11](/packages/laravel-notification-channels-discord)[beyondcode/laravel-mailbox

Handle incoming emails in your Laravel application.

1.1k1.0M4](/packages/beyondcode-laravel-mailbox)[yadahan/laravel-authentication-log

Laravel Authentication Log provides authentication logger and notification for Laravel.

416632.8k5](/packages/yadahan-laravel-authentication-log)[laravel-notification-channels/twilio

Provides Twilio notification channel for Laravel

2587.7M12](/packages/laravel-notification-channels-twilio)

PHPackages © 2026

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