PHPackages                             suver/yii2-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. suver/yii2-notifications

ActiveYii2-extension[Mail &amp; Notifications](/categories/mail)

suver/yii2-notifications
========================

You notifications

1.0.6(9y ago)161Apache-2.0PHP

Since Oct 9Pushed 9y ago1 watchersCompare

[ Source](https://github.com/suver/yii2-notifications)[ Packagist](https://packagist.org/packages/suver/yii2-notifications)[ RSS](/packages/suver-yii2-notifications/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (6)Dependencies (3)Versions (7)Used By (0)

Frapse Your Notifications
=========================

[](#frapse-your-notifications)

Your Notifications

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

[](#installation)

Either run

```
php composer.phar require suver/yii2-notifications

```

or add

```
"suver/yii2-notifications": "*"

```

Install migrations

```
yii migrate --migrationPath=@vendor/suver/yii2-notifications/migrations
```

Configurations
--------------

[](#configurations)

Add this module in your `modules` and `bootsrap` directive

```
'bootstrap' => [
    'notifications',
],
'modules' => [
        'notifications' => [
            'class' => 'suver\notifications\Module',
            // or
            //'detailViewWidget' => '\app\widgets\DetailView',
            //'gridViewWidget' => '\app\widgets\GridView',
            'identityClass' => '\app\models\User',
            'channels' => [
                [   // Email channel
                    'class' => '\suver\notifications\EmailChannel',
                    'init' => [
                        'from' => 'mail@example.com',
                    ],
                    'config' => [
                        'class' => 'yii\swiftmailer\Mailer',
                        'transport' => [
                            'class' => 'Swift_SmtpTransport',
                            'host' => 'smtp.yandex.ru',
                            'username' => 'mail@example.com',
                            'password' => '****',
                            'port' => '465',
                            'encryption' => 'ssl',
                        ],
                    ],
                ],
                [   // Yii2 Flash channel
                    'class' => '\suver\notifications\FlashNotificationsChannel',
                    'init' => [
                        'key' => 'info',
                    ],
                    'config' => [],
                ],
            ],
        ];
    ],

```

or if you wont include module with access rule configuration you must configure module with `as access` directive like example

```
'bootstrap' => [
    'notifications',
],
'modules' => [
        'notifications' => [
            'class' => 'suver\behavior\notifications\Module',
            'identityClass' => '\app\models\User',
            'channels' => [
                [   // Email channel
                    'class' => '\suver\notifications\EmailChannel',
                    'init' => [
                        'from' => 'mail@example.com',
                    ],
                    'config' => [
                        'class' => 'yii\swiftmailer\Mailer',
                        'transport' => [
                            'class' => 'Swift_SmtpTransport',
                            'host' => 'smtp.yandex.ru',
                            'username' => 'mail@example.com',
                            'password' => '****',
                            'port' => '465',
                            'encryption' => 'ssl',
                        ],
                    ],
                ],
                [   // Yii2 Flash channel
                    'class' => '\suver\notifications\FlashNotificationsChannel',
                    'init' => [
                        'key' => 'info',
                    ],
                    'config' => [],
                ],
            ],
            'as access' => [
                'class' => 'yii\filters\AccessControl',
                'rules' => [
                    [
                        'controllers'=>['notifications/default'],
                        'allow' => true,
                        'roles' => ['@']
                    ],
                    [
                        'controllers'=>['notifications/list'],
                        'allow' => true,
                        'roles' => ['@']
                    ],
                    [
                        'controllers'=>['notifications/template'],
                        'allow' => true,
                        'roles' => ['@']
                    ],
                ]
            ]
        ],
    ],

```

How USE
-------

[](#how-use)

```
Notifications::get('news-add', 1) // Return new instance notification model from "news-add" template for user with id=1
    ->setParams(['newsLink' => Url::to(['/news-feed/default/' . $event->sender->id], true)]) // set parrams for replace "{{newsLink}}" => /news-feed/default/1
    ->send(); // send message.

// Set new message body
Notifications::get('news-add', 1)->setMessage($message)

// Set new message body & new subject
Notifications::get('news-add', 1)->setMessage($message)->setSubject($subject)

// Set new message body & new subject & hold over message
Notifications::get('news-add', 1)->setMessage($message)->setSubject($subject)->holdOver()

// Select "flash-notifications" channel & set new message body & new subject & hold over message
Notifications::get('news-add', 1)->setChannel('flash-notifications')->setMessage($message)->setSubject($subject)->holdOver()

// Send notifications for all user selected channel
// You must implements UserNotificationsInterface and return from getNotificationChannels() method channel array as ['email', 'flash-notifications', 'and', 'other', 'notify']
Notifications::get('news-add', 1)->sendUserChannels()

```

How add new channel of notifications
------------------------------------

[](#how-add-new-channel-of-notifications)

configuration you channel

```

'channels' => [
    [   // You channel
        'class' => '\you\path\YouChannel',
        'init' => [
            // your init settings
        ],
        'config' => [
            // your transport settings
        ],
    ],

```

and write channel class as example

```
namespace suver\notifications;

use Yii;
use suver\notifications\models\Notifications as NotificationsModel;

/**
 * Class Notification
 * @package yii2-notifications
 */
class YouChannel implements ChannelInterface
{
    public $class;
    public $config;
    public $init;

    public function __construct($app, $config, $init) {
        $this->config = $config;
        $this->init = $init;
        $app->components = [
            // configure you needed components
        ];
    }

    public function getChannelName() {
        return 'you-channel-name';
    }

    public function init($config) {
        $this->config = $config;
    }

    public function send(NotificationsModel $object, $user) {
        $subject = $object->getSubject();
        $message = $object->getMessage();

        Yii::$app->session->setFlash($this->init['key'], $subject . " | " . $message);

        return true;
    }

}
```

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity67

Established project with proven stability

 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

Every ~1 days

Total

6

Last Release

3543d ago

### Community

Maintainers

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

---

Top Contributors

[![butkoden](https://avatars.githubusercontent.com/u/494321?v=4)](https://github.com/butkoden "butkoden (7 commits)")

---

Tags

notificationsyii2extensionfarpse

### Embed Badge

![Health badge](/badges/suver-yii2-notifications/health.svg)

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

###  Alternatives

[nterms/yii2-mailqueue

Email queue component for yii2 that works with yii2-swiftmailer.

84133.5k2](/packages/nterms-yii2-mailqueue)[odaialali/yii2-toastr

This is the Toastr extension for Yii 2. It encapsulates Toastr plugin in terms of Yii widgets, and makes ajax notification easy to implement.

1488.4k](/packages/odaialali-yii2-toastr)[tigrov/yii2-mailqueue

Yii2 mail queue component for yii2-swiftmailer.

196.4k](/packages/tigrov-yii2-mailqueue)

PHPackages © 2026

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