PHPackages                             eduardobrehm/notification-system - 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. eduardobrehm/notification-system

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

eduardobrehm/notification-system
================================

A sophisticated notification and redirection system for Laminas applications

11PHP

Since Dec 18Pushed 1y ago1 watchersCompare

[ Source](https://github.com/EduardoBrehm/notification-system)[ Packagist](https://packagist.org/packages/eduardobrehm/notification-system)[ RSS](/packages/eduardobrehm-notification-system/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

Laminas Notification System
===========================

[](#laminas-notification-system)

A sophisticated notification and redirection system built as a reusable Laminas module. This system provides a flexible and extensible way to handle notifications and intelligent redirections in your Laminas applications.

Features
--------

[](#features)

- Flexible notification system with support for different types (info, success, warning, error)
- Intelligent redirection system with configurable redirect maps
- Event-driven architecture for extensibility
- RESTful API endpoints for notification management
- Support for user-specific notifications
- Built-in support for read/unread status tracking
- Automatic cleanup of old notifications
- AJAX and regular HTTP support
- Fully configurable through module configuration
- Robust validation with DTO pattern
- Built-in caching support for improved performance
- Comprehensive error handling and logging
- 100% unit test coverage

Requirements
------------

[](#requirements)

- PHP 8.3 or later
- Laminas MVC Framework 3.6 or later
- PSR-3 compatible logger
- Composer for dependency management

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

[](#installation)

1. Install via composer:

```
composer require eduardobrehm/notification-system:dev-main
```

2. Enable the module in your `config/modules.config.php`:

```
return [
    // ... other modules
    'NotificationSystem',
];
```

3. Copy the provided configuration to your `config/autoload/` directory and modify as needed.

Usage
-----

[](#usage)

### Creating Notifications

[](#creating-notifications)

```
// In your controller or service
$notificationService = $container->get(NotificationService::class);

// Create a DTO for the notification
$notificationDto = new CreateNotificationDTO(
    'success',                    // type
    'Your action was successful', // message
    'user_profile_update',       // type_message
    123,                         // relation_id (optional)
    'user123'                    // user_id (optional)
);

try {
    $notification = $notificationService->createNotification($notificationDto);
} catch (NotificationValidationException $e) {
    // Handle validation errors
    $errors = $e->getErrors();
} catch (\Exception $e) {
    // Handle other errors
}
```

### Configuring Redirects

[](#configuring-redirects)

In your module config or local config:

```
return [
    'notification_system' => [
        'notification_types' => [
            'info' => [
                'icon' => 'fas fa-info-circle',
                'class' => 'info',
            ],
            'success' => [
                'icon' => 'fas fa-check-circle',
                'class' => 'success',
            ],
            'warning' => [
                'icon' => 'fas fa-exclamation-triangle',
                'class' => 'warning',
            ],
            'error' => [
                'icon' => 'fas fa-times-circle',
                'class' => 'error',
            ],
        ],
        'redirect_map' => [
            'user_profile_update' => [
                'route' => 'user/profile',
                'params' => [
                    'id' => 'relation_id',
                ],
            ],
        ],
    ],
];
```

### Handling Notifications in Frontend

[](#handling-notifications-in-frontend)

```
// Example using jQuery
$.get('/notification', { user_id: 'user123', unread: true }, function(response) {
    if (response.success) {
        response.data.notifications.forEach(function(notification) {
            // Handle each notification
        });
    }
}).fail(function(error) {
    // Handle errors
    console.error('Failed to fetch notifications:', error);
});
```

Advanced Features
-----------------

[](#advanced-features)

### Caching

[](#caching)

The system includes built-in caching support for improved performance:

- Caches unread notification counts
- Caches frequently accessed notifications
- Automatic cache invalidation on updates

```
// Cached unread count
$unreadCount = $notificationService->getUnreadCount('user123');

// Mark as read (automatically invalidates relevant caches)
$notificationService->markAsRead($notificationId, 'user123');
```

### Validation

[](#validation)

The system includes comprehensive validation:

- Type validation against configured notification types
- Message length and content validation
- Required field validation
- Custom validation rules can be added

### Error Handling

[](#error-handling)

Robust error handling with specific exceptions:

- `NotificationValidationException`: For validation errors
- `NotificationNotFoundException`: When a notification cannot be found
- Proper error logging with PSR-3 logger

Documentation
-------------

[](#documentation)

Complete technical documentation is available in both English and Portuguese:

### English Documentation

[](#english-documentation)

- [English Documentation (Markdown)](docs/documentation_en.md)
- [English Documentation (PDF)](docs/Laminas_Notification_System.pdf)

### Portuguese Documentation

[](#portuguese-documentation)

- [Documentação em Português (Markdown)](docs/documentacao_pt_BR.md)
- [Documentação em Português (PDF)](docs/Sistema_de_Notificacoes_Laminas.pdf)

Testing
-------

[](#testing)

The module comes with comprehensive unit tests. To run the tests:

```
composer test
```

For code coverage report:

```
composer test-coverage
```

Contributing
------------

[](#contributing)

1. Fork the repository
2. Create a feature branch
3. Write your changes with tests
4. Run `composer check` to ensure all tests pass
5. Submit a Pull Request

License
-------

[](#license)

MIT License. See [LICENSE.md](LICENSE.md) for details.

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance31

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity18

Early-stage or recently created project

 Bus Factor1

Top contributor holds 84.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.

### Community

Maintainers

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

---

Top Contributors

[![Eduardo-MEEmpresta](https://avatars.githubusercontent.com/u/127209390?v=4)](https://github.com/Eduardo-MEEmpresta "Eduardo-MEEmpresta (11 commits)")[![EduardoBrehm](https://avatars.githubusercontent.com/u/108371867?v=4)](https://github.com/EduardoBrehm "EduardoBrehm (2 commits)")

### Embed Badge

![Health badge](/badges/eduardobrehm-notification-system/health.svg)

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

###  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.3M227](/packages/tijsverkoyen-css-to-inline-styles)[minishlink/web-push

Web Push library for PHP

1.9k12.0M53](/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)
