PHPackages                             zanko-khaledi/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. zanko-khaledi/notifications

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

zanko-khaledi/notifications
===========================

v1.0.0(4mo ago)401MITPHPPHP ^8.2.0

Since Dec 24Pushed 4mo agoCompare

[ Source](https://github.com/zanko-khaledi/notifications)[ Packagist](https://packagist.org/packages/zanko-khaledi/notifications)[ RSS](/packages/zanko-khaledi-notifications/feed)WikiDiscussions master Synced 1mo ago

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

Notifications Package
=====================

[](#notifications-package)

A flexible, event-driven **Laravel package** for managing and dispatching notifications.
It provides both **synchronous** and **asynchronous (queued)** notification handling, with support for notification pools, custom drivers, and a base `Notification` class for building reusable notification types.

---

✨ Features
----------

[](#-features)

- **Synchronous &amp; Asynchronous sending**
    Send notifications immediately or queue them for background processing.
- **Job-based async execution**
    Uses Laravel’s `NotificationJob` to handle queued notifications.
- **Notification pools**
    Group multiple notification drivers together and process them in sequence.
- **Contracts for extensibility**
    Define your own notification drivers by implementing the provided interfaces.
- **Abstract Notification base class**
    Provides a reusable foundation for building custom notification types with user, notifiable models, and collections.

---

📦 Installation
--------------

[](#-installation)

Require the package in your Laravel app:

```
composer require zanko-khaledi/notifications:@dev
```

⚙️ Configuration
----------------

[](#️-configuration)

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

 php artisan vendor:publish --tag=notifications-model

 php artisan migrate
```

🚀 Usage
-------

[](#-usage)

### 1. Sending a notification

[](#1-sending-a-notification)

```
use ZankoKhaledi\Notifications\NotificationService;
use App\Notifications\MyNotification; // implements NotificationInterface

$service = app(NotificationService::class);

$user = auth()->user();
$notifiables = User::query()->where("id", ">", 2)->get();

$notification = app(MyNotification::class);
$notification->setUser($user)->setTitle("New notification")
        ->setMessage("Hello World")->setNotifiable($notifiables)

// Send synchronously
$service->send($notification);

// Send asynchronously (queued)
$service->send($notification, true);
```

### 2. Using a pool of drivers

[](#2-using-a-pool-of-drivers)

```
use App\Models\User;
use ZankoKhaledi\Notifications\Contracts\NotificationInterface;
use ZankoKhaledi\Notifications\NotificationService;
use App\Notifications\Telegram;
use App\Notifications\System;

$user = auth()->user();
$notifiables = User::query()->where("id", ">", 2)->get();

$notificationService = app(NotificationService::class);

// notifications sent via queue & background processing with pool

$notificationService->pool([
    Telegram::class,
    System::class
])->then(fn(NotificationInterface $notification) =>
    $notification->setUser($user)
                 ->setTitle("Hi")
                 ->setMessage("Hello World")
                 ->setNotifiable($notifiables)
);
```

This example demonstrates how to send notifications to multiple drivers (Telegram, System) using a pool.

### 3. Extending the abstract Notification class &amp; implementing NotificationInterface

[](#3-extending-the-abstract-notification-class--implementing-notificationinterface)

```
use ZankoKhaledi\Notifications\Notification;
use ZankoKhaledi\Notifications\Contracts\NotificationInterface;

class SystemNotification extends Notification implements NotificationInterface
{
    public function __construct()
    {
        parent::__construct();
    }

    public function setTitle(string $text = "") : static
    {
       $this->title = $text;
       return $this;
    }

    public function setMessage(string $text = "") : static
    {
        $this->message = $text;
        return $this;
    }

    public function send() : \ZankoKhaledi\Notifications\Models\Notification
    {
       $model = parent::send();

       // you can send you're notification via broadcast channel to websocket server then any consumers could catch the notification
       broadcast(new NotificationEvent($model));
       return $model;
    }
}
```

### 4. Example Driver: Telegram

[](#4-example-driver-telegram)

```
namespace App\Services\Notifications;

use Exception;
use Illuminate\Support\Facades\Http;
use ZankoKhaledi\Notifications\Contracts\NotificationInterface;
use ZankoKhaledi\Notifications\Models\Notification as ModelsNotification;
use ZankoKhaledi\Notifications\Notification;

class Telegram extends Notification implements NotificationInterface
{
    public function setTitle(string $text = ''): static
    {
        $this->title = $text;
        return $this;
    }

    public function setMessage(string $text = ''): static
    {
        $this->message = $text;
        return $this;
    }

    public function send(): ModelsNotification
    {
        $model = parent::send();

        $url = config('notifications.telegram_url', 'https://api.telegram.org/bot'.env('TELEGRAM_BOT_TOKEN').'/sendMessage');

        $response = Http::post($url, [
            'chat_id' => $this->getUser()?->id,
            'text'    => $this->getMessage(),
        ]);

        if ($response->successful()) {
            return $model;
        }

        throw new Exception(sprintf('Telegram API error: %s', $response->body()));
    }
}
```

📂 Package Structure
-------------------

[](#-package-structure)

```
src/
 ├── NotificationService.php
 ├── Notification.php (abstract base class)
 ├── Jobs/
 │    └── NotificationJob.php
 └── Contracts/
      ├── NotificationInterface.php
      ├── NotificationAsyncInterface.php
      ├── NotificationPoolInterface.php
      └── NotificationServiceInterface.php

```

⚡ Requirements
--------------

[](#-requirements)

#### PHP &gt;= 8.2

[](#php--82)

#### Laravel &gt;= 11

[](#laravel--11)

#### Queue driver configured (for async jobs)

[](#queue-driver-configured-for-async-jobs)

### 📜 License

[](#-license)

This package is open-sourced software licensed under the MIT license

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance75

Regular maintenance activity

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity47

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

137d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6e34e5d03473193a43463e890e1eafa0d7493723503999c503d9dd96a73ce789?d=identicon)[zanko-khaledi](/maintainers/zanko-khaledi)

---

Top Contributors

[![zanko-khaledi](https://avatars.githubusercontent.com/u/56206476?v=4)](https://github.com/zanko-khaledi "zanko-khaledi (9 commits)")

---

Tags

laravellaravel-packagenotification-servicephpphp8

### Embed Badge

![Health badge](/badges/zanko-khaledi-notifications/health.svg)

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

###  Alternatives

[beyondcode/laravel-mailbox

Handle incoming emails in your Laravel application.

1.1k1.0M4](/packages/beyondcode-laravel-mailbox)[laravel-notification-channels/apn

Apple APN Push Notification Channel

2021.9M4](/packages/laravel-notification-channels-apn)[fumeapp/modeltyper

Generate TypeScript interfaces from Laravel Models

196277.9k](/packages/fumeapp-modeltyper)[illuminate/mail

The Illuminate Mail package.

5910.1M391](/packages/illuminate-mail)[tzsk/sms

A robust and unified SMS gateway integration package for Laravel, supporting multiple providers.

320244.3k6](/packages/tzsk-sms)[therobfonz/laravel-mandrill-driver

Mandrill Driver for Laravel

773.5M](/packages/therobfonz-laravel-mandrill-driver)

PHPackages © 2026

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