PHPackages                             monkeyscloud/monkeyslegion-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. monkeyscloud/monkeyslegion-notifications

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

monkeyscloud/monkeyslegion-notifications
========================================

00PHP

Since Mar 19Pushed 1mo agoCompare

[ Source](https://github.com/MonkeysCloud/MonkeysLegion-Notifications)[ Packagist](https://packagist.org/packages/monkeyscloud/monkeyslegion-notifications)[ RSS](/packages/monkeyscloud-monkeyslegion-notifications/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

MonkeysLegion Notifications
===========================

[](#monkeyslegion-notifications)

A multi-channel notification system for the MonkeysLegion framework. Deeply integrated with the MonkeysLegion Queue, Query, and Mail packages while maintaining strict modular isolation.

🚀 Overview
----------

[](#-overview)

MonkeysLegion Notifications allows you to send messages across various delivery channels (like Mail and Database) following a clean, expressive API. It supports asynchronous delivery out-of-the-box by leveraging the `MonkeysLegion-Queue` system.

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

[](#-features)

- 📨 **Multi-Channel Delivery** - Send notifications via Mail, Database, and more.
- ⚡ **Queue Integration** - Automatically background heavy notification dispatches (e.g., SMTP) using the `ShouldQueue` interface.
- 🎯 **Notifiable Entities** - Easy integration with your Models/Entities via the `Notifiable` trait.
- 🏷️ **Attribute Triggers** - Trigger notifications automatically using PHP 8 attributes on DTOs or Entity properties.
- 🛡️ **PSR Compliant** - Built with PSR-14 event dispatching and standard isolation principles.

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

[](#-installation)

```
composer require monkeyscloud/monkeyslegion-notifications
```

📖 Basic Usage
-------------

[](#-basic-usage)

### 1. Define a Notification

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

```
namespace App\Notifications;

use MonkeysLegion\Notifications\Contracts\NotificationInterface;
use MonkeysLegion\Notifications\Messages\MailMessage;
use MonkeysLegion\Queue\Contracts\ShouldQueue; // Optional: for background sending

class InvoicePaid implements NotificationInterface, ShouldQueue
{
    public function __construct(public float $amount) {}

    public function via($notifiable): array
    {
        return ['mail', 'database'];
    }

    public function toMail($notifiable): MailMessage
    {
        return (new MailMessage)
            ->subject('Invoice Paid')
            ->line("You have paid an invoice of ${$this->amount}")
            ->action('View Invoice', 'https://example.com/invoice/1');
    }

    public function toDatabase($notifiable): array
    {
        return [
            'amount' => $this->amount,
            'message' => "Invoice of ${$this->amount} paid."
        ];
    }
}
```

### 2. Prepare your Notifiable Model

[](#2-prepare-your-notifiable-model)

```
use MonkeysLegion\Notifications\Traits\Notifiable;

class User
{
    use Notifiable;

    public string $email = 'user@example.com';
}
```

### 3. Send the Notification

[](#3-send-the-notification)

```
$user->notify(new InvoicePaid(99.99));
```

### 4. Attribute Triggers (Advanced)

[](#4-attribute-triggers-advanced)

You can automatically trigger notifications by using the `#[Notify]` attribute on your entities or their properties.

```
use MonkeysLegion\Notifications\Attributes\Notify;
use App\Notifications\LowBalanceWarning;

class Account
{
    use Notifiable;

    #[Notify(LowBalanceWarning::class)]
    public float $balance = 10.00;
}
```

The `AttributeProcessor` scans for these triggers during event lifespan.

📦 Project Structure
-------------------

[](#-project-structure)

```
monkeyslegion-notifications/
├── src/
│   ├── Attributes/
│   │   ├── Notify.php              # Attribute-driven triggers
│   │   └── AttributeProcessor.php  # Logic to scan and trigger
│   ├── Channels/
│   │   ├── ChannelInterface.php    # Blueprint for all drivers
│   │   ├── DatabaseChannel.php     # Logic for saving to DB
│   │   └── MailChannel.php         # Logic for sending emails
│   ├── Contracts/
│   │   ├── NotifiableInterface.php # For entities that receive notifications
│   │   └── NotificationInterface.php # For the notification classes themselves
│   ├── Events/
│   │   ├── NotificationSent.php    # PSR-14 event
│   │   └── NotificationFailed.php  # PSR-14 event
│   ├── Exceptions/
│   │   └── CouldNotSendNotification.php
│   ├── Jobs/
│   │   └── SendNotificationJob.php  # Queue wrapper
│   ├── Messages/
│   │   ├── MailMessage.php         # Fluent builder for mail content
│   │   └── DatabaseMessage.php     # Formatter for DB arrays
│   ├── Traits/
│   │   └── Notifiable.php          # The "Glue" for your User/Entity models
│   └── NotificationManager.php     # The "Dispatcher" (Entry point)
├── database/
│   └── migrations/                 # Default sql migrations for DB channel
├── config/
│   └── notifications.mlc           # MonkeysLegion Config format

```

📡 Scope &amp; Integration
-------------------------

[](#-scope--integration)

This package is designed as a **Producer**. It formats messages and submits them to the respective underlying systems:

- **Queue**: If a notification implements `ShouldQueue`, it is wrapped in a `SendNotificationJob` and handed to `MonkeysLegion-Queue`.
- **Database**: Records are persisted using `MonkeysLegion-Query`.
- **Mail**: Content is handed over to `MonkeysLegion-Mail`.

🚦 Roadmap
---------

[](#-roadmap)

### Phase 1: Core Foundation (Complete)

[](#phase-1-core-foundation-complete)

- Basic Contracts &amp; Interfaces
- Database Channel implementation
- Queue Integration via `ShouldQueue`
- `Notifiable` Trait &amp; `NotificationManager`

### Phase 2: Built-in Channels (Complete)

[](#phase-2-built-in-channels-complete)

- Mail Channel Integration (using MonkeysLegion-Mail)
- `MailMessage` fluent builder

### Phase 3: Advanced Integration (In Progress)

[](#phase-3-advanced-integration-in-progress)

- PSR-14 Event Listeners
- `#[Notify]` attribute processor
- Notification History UI components (Skeleton integration)

---

Made with ❤️ by MonkeysLegion

Component,Purpose,Status Notification Discovery,Scan for #\[Notify\] attributes on DTOs.,In Progress Polymorphic Storage,Migration for a notifications table that works with any Entity ID.,Needed "The ""Anonymous"" Notifiable",For routing notifications to raw emails/phone numbers.,Needed Templating Engine,Integration with your framework's View engine for HTML emails.,Needed

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance63

Regular maintenance activity

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity11

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/51e4df19377776baa8eafb605d9e7d2374b855c686f552c20d6856e94e3597c3?d=identicon)[yorchperaza](/maintainers/yorchperaza)

---

Top Contributors

[![Amanar-Marouane](https://avatars.githubusercontent.com/u/155680356?v=4)](https://github.com/Amanar-Marouane "Amanar-Marouane (1 commits)")

### Embed Badge

![Health badge](/badges/monkeyscloud-monkeyslegion-notifications/health.svg)

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

###  Alternatives

[tijsverkoyen/css-to-inline-styles

CssToInlineStyles is a class that enables you to convert HTML-pages/files into HTML-pages/files with inline styles. This is very useful when you're sending emails.

5.8k505.3M228](/packages/tijsverkoyen-css-to-inline-styles)[minishlink/web-push

Web Push library for PHP

1.9k12.0M52](/packages/minishlink-web-push)[laravel-notification-channels/twilio

Provides Twilio notification channel for Laravel

2587.7M12](/packages/laravel-notification-channels-twilio)[spatie/url-signer

Generate a url with an expiration date and signature to prevent unauthorized access

4422.3M16](/packages/spatie-url-signer)[mattketmo/email-checker

Throwaway email detection library

2742.0M5](/packages/mattketmo-email-checker)[laravel-notification-channels/discord

Laravel notification driver for Discord.

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

PHPackages © 2026

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