PHPackages                             karnoweb/laravel-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. [Database &amp; ORM](/categories/database)
4. /
5. karnoweb/laravel-notification

ActiveLibrary[Database &amp; ORM](/categories/database)

karnoweb/laravel-notification
=============================

Multi-channel notification business layer for Laravel

1.0.0(3mo ago)00MITPHPPHP ^8.2

Since Mar 10Pushed 3mo agoCompare

[ Source](https://github.com/karnoweb/laravel-notification)[ Packagist](https://packagist.org/packages/karnoweb/laravel-notification)[ RSS](/packages/karnoweb-laravel-notification/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependencies (5)Versions (2)Used By (0)

Karnoweb Laravel Notification
=============================

[](#karnoweb-laravel-notification)

Multi-channel notification business layer for Laravel: configurable channels per event, user and global overrides, templates, logging and queuing.

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

[](#installation)

```
composer require karnoweb/laravel-notification
```

### Publish config (optional)

[](#publish-config-optional)

```
php artisan vendor:publish --tag=karnoweb-notification-config
```

Migrations run automatically from the package; run `php artisan migrate` to create package tables (with prefix).

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

[](#configuration)

In `config/karnoweb-notification.php`:

- **table\_prefix**: Prefix for package tables (default: `karnoweb_`). Tables: `{prefix}notification_logs`, `{prefix}notification_templates`, `{prefix}notification_preferences`.
- **channels**: Default and per-event channel config (`enabled`, `togglable`).
- **queued\_channels**: Channels that are sent via queue (e.g. `['email', 'sms']`).
- **queue\_jobs**: Job class per channel for queued sending.
- **log\_model**: Model used for notification logs (default: package model).
- **mailable**: Mailable class for email channel (receives payload array).
- **template\_model**: Model for notification templates (default: package `NotificationTemplate`).

Usage
-----

[](#usage)

### Sending a notification

[](#sending-a-notification)

Build a `NotificationMessage` with event (string), context and per-channel payloads, then dispatch:

```
use Karnoweb\LaravelNotification\NotificationChannelEnum;
use Karnoweb\LaravelNotification\NotificationDispatcher;
use Karnoweb\LaravelNotification\Messages\NotificationMessage;

$message = NotificationMessage::make('auth_register')
    ->withContext(['user_name' => $user->name, 'action_url' => url('/login')])
    ->withChannel(NotificationChannelEnum::DATABASE, ['title' => '...', 'body' => '...'])
    ->withChannel(NotificationChannelEnum::EMAIL, ['subject' => '...', 'body' => '...']);

app(NotificationDispatcher::class)->dispatch($user, $message, $profile, [
    'notification_class' => RegisterNotification::class,
]);
```

### Custom drivers

[](#custom-drivers)

Implement `Karnoweb\LaravelNotification\Contracts\NotificationChannelDriver` and register in your app service provider:

```
$this->app->singleton(
    \Karnoweb\LaravelNotification\NotificationChannelEnum::SMS->driverBinding(),
    \App\Notifications\Drivers\SmsChannelDriver::class
);
```

### User and global overrides

[](#user-and-global-overrides)

Implement and bind:

- `Karnoweb\LaravelNotification\Contracts\GlobalChannelOverridesResolver` (admin settings per event).
- `Karnoweb\LaravelNotification\Contracts\UserChannelOverridesResolver` (user/profile settings per event).

Then `NotificationPreferenceResolver` will use them when resolving enabled channels.

### Queued jobs

[](#queued-jobs)

Extend `Karnoweb\LaravelNotification\Jobs\SendChannelNotificationJob` and define `channel()`:

```
namespace App\Jobs\Notifications;

use Karnoweb\LaravelNotification\Jobs\SendChannelNotificationJob;
use Karnoweb\LaravelNotification\NotificationChannelEnum;

class SendEmailNotificationJob extends SendChannelNotificationJob
{
    protected function channel(): NotificationChannelEnum
    {
        return NotificationChannelEnum::EMAIL;
    }
}
```

Set `queue_jobs.email` (and `queue_jobs.sms`) in config to your job classes.

### Direct send (no Notification class)

[](#direct-send-no-notification-class)

Send from anywhere without defining a notification class:

```
use Karnoweb\LaravelNotification\NotificationService;

$service = app(NotificationService::class);

// Synchronous: builds message and dispatches (email/sms still queued by channel)
$service->sendDirect($user, 'order_ready', [
    'database' => ['title' => 'Order ready', 'body' => 'Your order #123 is ready.'],
    'email' => ['subject' => 'Order ready', 'body' => '...'],
], $profile, ['notification_class' => null]);

// Entire send queued (dispatcher runs in a job)
$service->queueSendDirect($user, 'order_ready', [
    'database' => ['title' => 'Order ready', 'body' => '...'],
], $profile);
```

### User preferences (table)

[](#user-preferences-table)

User channel preferences are stored in `{prefix}notification_preferences`. The package provides `DatabaseUserChannelOverridesResolver` by default. Use `NotificationPreference::setChannels($notifiable, $event, $channels)` and `NotificationPreference::getAllForNotifiable($notifiable)` to read/write from your app.

Repository
----------

[](#repository)

- **Git**: `git@github.com:karnoweb/laravel-notification.git`
- **Namespace**: `Karnoweb\LaravelNotification`

### Push to GitHub

[](#push-to-github)

From the package directory:

```
cd packages/karnoweb/laravel-notification
git init
git remote add origin git@github.com:karnoweb/laravel-notification.git
git add .
git commit -m "Initial package"
git branch -M main
git push -u origin main
```

License
-------

[](#license)

MIT

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance80

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity46

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

Unknown

Total

1

Last Release

108d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a6a881e293406595d74617357c2477180a2a48cb6613acb3395652bd00147f78?d=identicon)[sajadsoft1](/maintainers/sajadsoft1)

---

Top Contributors

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

---

Tags

laraveldatabaseemailnotificationsmschannels

###  Code Quality

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/karnoweb-laravel-notification/health.svg)

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[spatie/laravel-health

Monitor the health of a Laravel application

87411.3M153](/packages/spatie-laravel-health)[illuminate/database

The Illuminate Database package.

2.8k54.1M11.1k](/packages/illuminate-database)[larastan/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

6.4k51.0M7.6k](/packages/larastan-larastan)[kreait/laravel-firebase

A Laravel package for the Firebase PHP Admin SDK

1.3k18.0M46](/packages/kreait-laravel-firebase)[laravel/cashier

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

2.5k28.4M137](/packages/laravel-cashier)

PHPackages © 2026

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