Search by

ogzcnozdmr / notifier

ogzcnozdmr

Laravel client for a self-hosted notification service.

Package info

github.com/ogzcnozdmr/notifier

pkg:composer/ogzcnozdmr/notifier

Statistics

Installs: 2

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.1.1 2026-12-01 11:19 UTC

This package is auto-updated.

Last update: 2026-12-01 11:26:41 UTC


README

Operational notifications for Laravel: Telegram, mail, Slack, Discord, WhatsApp, SMS, push, webhooks and the database behind one API. Channels can be used on their own, through the facade, or delegated to a central notification service.

Requires PHP 8.4 and Laravel 13.

Installation

composer require ogzcnozdmr/notifier

Using a channel directly

use Ogzcnozdmr\Notifier\Channels\Telegram;

$telegram = new Telegram($botToken, $chatId);

$telegram->send('Backup finished', '42 GB in 6 minutes');

send() returns true or false and never throws. Every channel works the same way:

Channel Constructor
Telegram token, chatId, threadId = null
Mail to, mailer = null, from = null
Slack webhookUrl
Discord webhookUrl
WhatsApp token, phoneNumberId, to, template = null, language = 'en'
Netgsm username, password, header, to
IletiMerkezi key, hash, sender, to
Fcm credentials, tokens = null, topic = null
Webhook url, secret = null, headers = []
Database table = 'notifier_notifications', connection = null

Mail uses the mailers of the application. WhatsApp uses the Meta Cloud API; outside the 24 hour conversation window a template with two body parameters (title, details) is required. Fcm takes the service account JSON as an array or a file path. Webhook signs the body when a secret is given: X-Notifier-Signature is sha256= followed by the HMAC of timestamp.body.

Using the facade

Set the channels once in .env:

NOTIFIER_CHANNELS=telegram,mail
NOTIFIER_TELEGRAM_TOKEN=123456:ABC
NOTIFIER_TELEGRAM_CHAT_ID=-1001234567890
NOTIFIER_MAIL_TO=ops@example.com
use Ogzcnozdmr\Notifier\Facades\Notifier;

Notifier::critical('Payment failed', 'Bank declined order #1234')->send();

Notifier::warning('Low stock')
    ->url('https://shop.example.com/products/42')
    ->context(['sku' => 'A-42', 'left' => 3])
    ->channels('slack', 'database')
    ->send();

Levels are info, warning, error and critical. Sending never throws. A channel that cannot be reached is retried through the queue for a few hours, so a queue worker should be running. Channels without credentials are skipped.

The remaining settings are in the config file:

php artisan vendor:publish --tag=notifier-config
php artisan vendor:publish --tag=notifier-migrations   # database channel

Send a test notification:

php artisan notifier:test
php artisan notifier:test telegram mail

Using a notification service

When NOTIFIER_URL and NOTIFIER_KEY are set, notifications are posted to that service instead and it decides where they go.

NOTIFIER_URL=https://notifications.example.com
NOTIFIER_KEY=your-project-key

Exceptions

Report unhandled exceptions from bootstrap/app.php:

->withExceptions(function (Exceptions $exceptions) {
    Notifier::handles($exceptions);
})

The same exception is reported at most once a minute.

Custom channels

Notifier::extend('pager', fn () => new PagerChannel(config('services.pager.key')));

A channel extends Ogzcnozdmr\Notifier\Channels\Channel and implements configured() and deliver().

Testing

Notifier::fake();

// ...

Notifier::assertSent('Payment failed');
Notifier::assertSentWithLevel('critical');
Notifier::assertSent(fn ($notification) => $notification->context['order'] === 1234);
Notifier::assertNothingSent();

License

MIT