PHPackages                             azaharizaman/nexus-notifier - 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. azaharizaman/nexus-notifier

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

azaharizaman/nexus-notifier
===========================

Framework-agnostic notification engine for multi-channel communication (Email, SMS, Push, In-App)

v0.1.0-alpha1(2mo ago)025MITPHPPHP ^8.3

Since May 5Pushed 2mo agoCompare

[ Source](https://github.com/azaharizaman/nexus-notifier)[ Packagist](https://packagist.org/packages/azaharizaman/nexus-notifier)[ RSS](/packages/azaharizaman-nexus-notifier/feed)WikiDiscussions main Synced 1w ago

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

Nexus\\Notifier
===============

[](#nexusnotifier)

**Framework-agnostic notification engine for multi-channel communication.**

Purpose
-------

[](#purpose)

`Nexus\Notifier` provides a unified, decoupled interface for sending notifications across multiple channels (Email, SMS, Push Notifications, In-App Messages) without coupling your business logic to specific vendors or delivery mechanisms.

Core Philosophy
---------------

[](#core-philosophy)

**"Define the message once, deliver everywhere."**

This package implements the **Channel Agnosticism** principle: your business logic triggers notifications without knowing *how* they're delivered. The consuming application (Atomy) provides the concrete implementations for each channel.

Key Features
------------

[](#key-features)

- **Multi-Channel Support**: Email, SMS, Push Notifications, In-App messaging
- **Channel Agnosticism**: Business logic remains decoupled from delivery mechanisms
- **Single Definition**: One notification event contains all channel variations
- **Asynchronous Delivery**: Queue-based delivery prevents blocking
- **Priority Handling**: Critical notifications bypass normal queues
- **Template Engine**: Variable substitution and multi-language support
- **Delivery Tracking**: Complete lifecycle tracking (Pending → Sent → Delivered → Failed)
- **Preference Management**: Per-recipient channel and category preferences
- **Audit Trail**: Full logging integration via `Nexus\AuditLogger`
- **Rate Limiting**: Prevents spam and abuse
- **Fallback Channels**: Automatic fallback if primary channel fails

Architecture
------------

[](#architecture)

This package follows Nexus's **"Logic in Packages, Implementation in Applications"** principle:

- **Package (`packages/Notifier/`)**: Defines contracts, business logic, and value objects
- **Application (`apps/Atomy/`)**: Implements repositories, models, and channel handlers

### Package Structure

[](#package-structure)

```
packages/Notifier/
├── composer.json
├── LICENSE
├── README.md
└── src/
    ├── Contracts/              # Interfaces (REQUIRED)
    │   ├── NotificationManagerInterface.php
    │   ├── NotificationInterface.php
    │   ├── NotifiableInterface.php
    │   ├── NotificationChannelInterface.php
    │   ├── NotificationTemplateRepositoryInterface.php
    │   ├── NotificationHistoryRepositoryInterface.php
    │   ├── NotificationRendererInterface.php
    │   ├── NotificationQueueInterface.php
    │   ├── DeliveryStatusTrackerInterface.php
    │   └── NotificationPreferenceRepositoryInterface.php
    ├── Exceptions/             # Domain exceptions
    │   ├── NotificationException.php
    │   ├── NotificationNotFoundException.php
    │   ├── InvalidChannelException.php
    │   ├── InvalidRecipientException.php
    │   ├── DeliveryFailedException.php
    │   ├── RateLimitExceededException.php
    │   └── TemplateRenderException.php
    ├── Services/               # Business logic
    │   ├── NotificationManager.php
    │   └── ChannelRouter.php
    └── ValueObjects/           # Immutable data structures
        ├── Priority.php
        ├── Category.php
        ├── DeliveryStatus.php
        ├── NotificationContent.php
        └── ChannelType.php

```

Requirements Addressed
----------------------

[](#requirements-addressed)

This package addresses the following requirements from `REQUIREMENTS.csv`:

- **FR-NOT-101**: Channel agnosticism - business services trigger notifications without knowing delivery method
- **FR-NOT-102**: Single notification definition containing all channel variations
- **FR-NOT-103**: Recipient abstraction via `NotifiableInterface`
- **FR-NOT-104**: Asynchronous notification delivery via queue
- **BUS-NOT-0001 to BUS-NOT-0010**: Business requirements for multi-channel delivery, consistency, retry logic, etc.
- **FUN-NOT-0185 to FUN-NOT-0204**: Functional requirements for notification management

See `REQUIREMENTS.csv` for complete list.

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

[](#installation)

This package is part of the Nexus monorepo. To use it in the Atomy application:

```
composer require azaharizaman/nexus-notifier:"*@dev"
```

Usage
-----

[](#usage)

### 1. Define a Notification

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

Create a notification class implementing `NotificationInterface`:

```
use Nexus\Notifier\Contracts\NotificationInterface;
use Nexus\Notifier\ValueObjects\Priority;
use Nexus\Notifier\ValueObjects\Category;

final class PayslipAvailableNotification implements NotificationInterface
{
    public function __construct(
        private readonly string $employeeName,
        private readonly string $month,
        private readonly string $downloadUrl
    ) {}

    public function toEmail(): array
    {
        return [
            'subject' => "Your {$this->month} Payslip is Ready",
            'body' => "Hello {$this->employeeName}, your payslip for {$this->month} is now available. Download it here: {$this->downloadUrl}",
        ];
    }

    public function toSms(): string
    {
        return "Your {$this->month} payslip is ready. Download: {$this->downloadUrl}";
    }

    public function toPush(): array
    {
        return [
            'title' => 'Payslip Available',
            'body' => "Your {$this->month} payslip is ready",
            'action' => $this->downloadUrl,
        ];
    }

    public function toInApp(): array
    {
        return [
            'title' => 'Payslip Available',
            'message' => "Your {$this->month} payslip is now available for download.",
            'link' => $this->downloadUrl,
        ];
    }

    public function getPriority(): Priority
    {
        return Priority::Normal;
    }

    public function getCategory(): Category
    {
        return Category::Transactional;
    }
}
```

### 2. Send a Notification

[](#2-send-a-notification)

```
use Nexus\Notifier\Contracts\NotificationManagerInterface;

final class PayrollManager
{
    public function __construct(
        private readonly NotificationManagerInterface $notifier
    ) {}

    public function publishPayslip(string $employeeId): void
    {
        // Business logic to generate payslip...

        $notification = new PayslipAvailableNotification(
            employeeName: $employee->getName(),
            month: 'January 2025',
            downloadUrl: $payslipUrl
        );

        // Send via all preferred channels
        $this->notifier->send($employee, $notification);
    }
}
```

### 3. Implement Notifiable

[](#3-implement-notifiable)

Your recipient entity must implement `NotifiableInterface`:

```
use Nexus\Notifier\Contracts\NotifiableInterface;

final class Employee implements NotifiableInterface
{
    public function getNotificationEmail(): ?string
    {
        return $this->email;
    }

    public function getNotificationPhone(): ?string
    {
        return $this->mobilePhone;
    }

    public function getNotificationDeviceTokens(): array
    {
        return $this->deviceTokens ?? [];
    }

    public function getNotificationLocale(): string
    {
        return $this->preferredLocale ?? 'en';
    }

    public function getNotificationTimezone(): string
    {
        return $this->timezone ?? 'UTC';
    }
}
```

User Stories Solved
-------------------

[](#user-stories-solved)

### 1. System Administrator Story

[](#1-system-administrator-story)

**Problem**: Switching SMS vendors requires code changes across multiple packages.

**Solution**:

```
// Only change binding in AppServiceProvider
$this->app->singleton(SmsChannelInterface::class, MessageBirdSmsChannel::class);
// No changes to Payroll, FieldService, or any other package!
```

### 2. Package Developer Story

[](#2-package-developer-story)

**Problem**: Implementing notifications requires understanding SMTP, SMS APIs, etc.

**Solution**:

```
// Simple, focused business logic
$this->notifier->send($user, new InvoiceReadyNotification($invoice));
```

### 3. Customer Relations Manager Story

[](#3-customer-relations-manager-story)

**Problem**: Need multi-channel confirmation after booking.

**Solution**: The system automatically sends both email and SMS based on recipient preferences when you call `$notifier->send()`.

Dependencies
------------

[](#dependencies)

This package depends on:

- **`azaharizaman/nexus-audit-logger`**: For audit trail logging
- **`azaharizaman/nexus-connector`**: For actual email/SMS delivery via external providers
- **`azaharizaman/nexus-identity`**: For recipient user data
- **`azaharizaman/nexus-setting`**: For notification preferences

Integration Points
------------------

[](#integration-points)

The consuming application (Atomy) must implement:

1. **Channel Handlers**: Email, SMS, Push, In-App channel implementations
2. **Repositories**: Template, History, Preference repositories with database persistence
3. **Queue System**: For asynchronous delivery
4. **Service Provider Bindings**: Wire all interfaces to concrete implementations

See `docs/NOTIFIER_IMPLEMENTATION.md` for complete implementation guide.

Testing
-------

[](#testing)

Package tests are unit tests with mocked repositories. Atomy tests are feature tests with database.

License
-------

[](#license)

MIT License - see LICENSE file for details.

Support
-------

[](#support)

Part of the Nexus ERP Monorepo.

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance84

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

 Bus Factor1

Top contributor holds 76.6% 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

81d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/117408?v=4)[Azahari Zaman](/maintainers/azaharizaman)[@azaharizaman](https://github.com/azaharizaman)

---

Top Contributors

[![azaharizaman](https://avatars.githubusercontent.com/u/117408?v=4)](https://github.com/azaharizaman "azaharizaman (461 commits)")[![Copilot](https://avatars.githubusercontent.com/in/1143301?v=4)](https://github.com/Copilot "Copilot (139 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")

### Embed Badge

![Health badge](/badges/azaharizaman-nexus-notifier/health.svg)

```
[![Health](https://phpackages.com/badges/azaharizaman-nexus-notifier/health.svg)](https://phpackages.com/packages/azaharizaman-nexus-notifier)
```

###  Alternatives

[symfony/mailer

Helps sending emails

1.6k409.1M1.5k](/packages/symfony-mailer)[symfony/cache

Provides extended PSR-6, PSR-16 (and tags) implementations

4.2k373.5M3.4k](/packages/symfony-cache)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.7k38.9k](/packages/matomo-matomo)[symfony/notifier

Sends notifications via one or more channels (email, SMS, ...)

80343.9M442](/packages/symfony-notifier)[illuminate/mail

The Illuminate Mail package.

5910.6M528](/packages/illuminate-mail)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k16](/packages/tempest-framework)

PHPackages © 2026

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