PHPackages                             sankaest/yii2-notification - 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. sankaest/yii2-notification

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

sankaest/yii2-notification
==========================

This module for renders a message from session flash (with ajax, pjax support and etc.)

1.0.1(5y ago)010MITPHP

Since Oct 29Pushed 5y ago1 watchersCompare

[ Source](https://github.com/sankaest/yii2-notification)[ Packagist](https://packagist.org/packages/sankaest/yii2-notification)[ Docs](https://github.com/sankaest/yii2-notification)[ RSS](/packages/sankaest-yii2-notification/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (1)Versions (3)Used By (0)

Yii2-notification-wrapper
=========================

[](#yii2-notification-wrapper)

[![Latest Stable Version](https://camo.githubusercontent.com/4051a8972398ecb04e3dc29183ed957cd0d8317b8f58159d75c3a75265e0d198/68747470733a2f2f706f7365722e707567782e6f72672f73616e6b616573742f796969322d6e6f74696669636174696f6e2f762f737461626c65)](https://packagist.org/packages/sankaest/yii2-notification)[![Total Downloads](https://camo.githubusercontent.com/8c6dc7bd03c0ca55ec5c3bb62f86e746a53d0c5403ab77d99a39a79e6a84ccb1/68747470733a2f2f706f7365722e707567782e6f72672f73616e6b616573742f796969322d6e6f74696669636174696f6e2f646f776e6c6f616473)](https://packagist.org/packages/sankaest/yii2-notification)[![Monthly Downloads](https://camo.githubusercontent.com/a54b842374063f5adaf9588fcb7484eff82d0ad0754d41c5a0519421da32822e/68747470733a2f2f706f7365722e707567782e6f72672f73616e6b616573742f796969322d6e6f74696669636174696f6e2f642f6d6f6e74686c79)](https://packagist.org/packages/sankaest/yii2-notification)[![Daily Downloads](https://camo.githubusercontent.com/9195e1b22305608e47519d0c01fd43d4bb18c79775216d8ba38a48e68eba1c7d/68747470733a2f2f706f7365722e707567782e6f72672f73616e6b616573742f796969322d6e6f74696669636174696f6e2f642f6461696c79)](https://packagist.org/packages/sankaest/yii2-notification)[![License](https://camo.githubusercontent.com/67185f34b2bfc8a0b2398c2ca8c2920d68109bd6c1ad700f969a2aad017c7eab/68747470733a2f2f706f7365722e707567782e6f72672f73616e6b616573742f796969322d6e6f74696669636174696f6e2f6c6963656e7365)](https://packagist.org/packages/sankaest/yii2-notification)

Yii2-notification-wrapper module renders a message from session flash (with ajax support). All flash messages are displayed in the sequence they were assigned using setFlash.

[!["Demo"](docs/img/noty-demo.jpg)](docs/img/noty-demo.jpg)

You can set message as following:

```
public function actionIndex(){
   ...
    Yii::$app->session->setFlash('error',   'noty error');
    Yii::$app->session->setFlash('info',    'noty info');
    Yii::$app->session->setFlash('success', 'noty success');
    Yii::$app->session->setFlash('warning', 'noty warning');
   ...
    return $this->render('index');
}

// or in ajax action

public function actionAjax(){
    ...
    Yii::$app->session->setFlash('error',   'ajax error');
    Yii::$app->session->setFlash('info',    'ajax info');
    Yii::$app->session->setFlash('success', 'ajax success');
    Yii::$app->session->setFlash('warning', 'ajax warning');
    ...
    $data = 'Some data to be returned in response to ajax request';
    Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
    return $data;
 }
```

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

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

To install with bower package for one of supported layers, either run

```
$ php composer.phar require sankaest/yii2-notification "*"
# if you want use it
$ php composer.phar require bower-asset/noty "^2.3"
$ php composer.phar require bower-asset/jquery-growl "^1.3"
```

or add

```
"sankaest/yii2-notification": "*",
"bower-asset/noty": "^2.3",
"bower-asset/jquery-growl": "^1.3"
```

to the `require` section of your `composer.json` file.

Configure application
---------------------

[](#configure-application)

Let's start with defining module in our config file (`@common/config/main.php`):

```
'modules' => [
    'noty' => [
        'class' => 'sankaest\modules\notification\Module',
    ],
],
```

That's all, now you have module installed and configured.

Usage
-----

[](#usage)

This package comes with a Wrapper widget that can be used to regularly poll the server for new notifications and trigger them visually using either Noty (or Toastr, or Growl etc.).

This widget should be used in your main layout file as follows:

```
use sankaest\modules\notification\Wrapper;

// for Bootstrap Alert
echo Wrapper::widget();

// or for Growl
echo Wrapper::widget([
    'layerClass' => 'sankaest\modules\notification\layers\Growl',
]);

// or for Noty
echo Wrapper::widget([
    'layerClass' => 'sankaest\modules\notification\layers\Noty',
]);
```

Advanced usage
==============

[](#advanced-usage)

Every layer may be customizable from parameter `options` in the widget. For more information - read documentation.

```
use sankaest\modules\notification\Wrapper;

echo Wrapper::widget([
    'layerClass' => 'sankaest\modules\notification\layers\Noty',
    'layerOptions'=>[
        // for every layer (by default)
        'layerId' => 'noty-layer',
        'customTitleDelimiter' => '|',
        'overrideSystemConfirm' => true,
        'showTitle' => true,

        // for custom layer
        'registerAnimateCss' => true,
        'registerButtonsCss' => true
    ],

    // clientOptions
    'options' => [
        'dismissQueue' => true,
        'layout' => 'topRight',
        'timeout' => 3000,
        'theme' => 'relax',

        // and more for this library...
    ],
]);
```

Some libraries can override System Confirm for links as:

```
Go!
```

Custom title
------------

[](#custom-title)

If you want change notification title, you can use `customTitleDelimiter` in our messages

```
    echo  Wrapper::widget([
        'layerClass' => '...',
        'layerOptions' => [
            'customTitleDelimiter' = '|', // by default
        ],
    ]);
```

and set message in action as

```
public function actionIndex(){
    ...
     Yii::$app->session->setFlash('success', 'CUSTOM TITLE | noty success');
    ...
 }
```

Layer Id
--------

[](#layer-id)

If you want paste notification message in custom div, you can use `layerId`. For example:

```
// In layout:
    $layerParams = [
        'layerClass' => '...',
        'layerOptions' => [
            ...
        ],
    ];

    if (isset($this->params['layerParams']){
        $layerParams = \yii\helpers\ArrayHelper::merge($layerParams, $this->params['layerParams']);
    }
    echo  Wrapper::widget($layerParams);

// In view:
    $this->params['layerParams'] = [
        'layerClass' => 'sankaest\modules\notification\layers\Alert',
        'layerOptions' => [
            'layerId' => 'my-noty-id',
        ],
    ];

    echo ''; // and notification will be placed here
```

Disable showNoty after ajax calls
---------------------------------

[](#disable-shownoty-after-ajax-calls)

- In Ajax script

```
    $.ajax({
        method: 'GET',
        dataType: 'json',
        url: someresouceurl,
        showNoty: false, // add this for disable notification
        success: function(data) {
        }
    });
```

- In Pjax

```
    Pjax::begin([
        'clientOptions' => [
            'showNoty' => false
        ]
    ]);
    ... pjax container ...
    Pjax::end();
```

Noty Exceptions
---------------

[](#noty-exceptions)

For example:

```
use sankaest\modules\notification\exceptions\NotyFlashException;
use sankaest\modules\notification\exceptions\NotyErrorException;

public function actionUpdate($id)
{
    $model = $this->findModel($id);

    try {
        if ($model->load(Yii::$app->request->post()) && $model->save()) {
            return $this->redirect(['view', 'id' => $model->id]);
        } else {
            return $this->render('update', [
                'model' => $model,
            ]);
        }
    } catch (NotyFlashException $e) {
        $e->catchFlash();
    }
}

protected function findModel($id)
{
    if (($model = Post::findOne($id)) !== null) {
        return $model;
    } else {
        throw new NotyErrorException('The requested page does not exist.');
    }
}
```

Supported layers
----------------

[](#supported-layers)

Currently supported layers are:

Library (Layer)BowerConfirmProject homepageDocsBootstrap Alert--[read](docs/Alert.md)Bootstrap Notifyremarkable-bootstrap-notify-[read](docs/BootstrapNotify.md)Growljquery-growl-[read](docs/Growl.md)iGrowligrowl-[read](docs/Igrowl.md)jQuery Notifyjquery.notify-[read](docs/JqueryNotify.md)jQuery Notify Barjqnotifybar-[read](docs/JqueryNotifyBar.md)jQuery Toasterjquery.toaster-[read](docs/JqueryToaster.md)jQuery Toast Pluginjquery-toast-plugin-[read](docs/JqueryToastPlugin.md)Lobiboxlobibox+[read](docs/Lobibox.md)Notienotie+[read](docs/Notie.md)Notific8notific8-[read](docs/Notific8.md)NotifItnotifit+[read](docs/NotifIt.md)Notify.jsnotifyjs-[read](docs/Notifyjs.md)Notynoty+[read](docs/Noty.md)PNotifypnotify+[read](docs/PNotify.md)Sweetalertsweetalert+[read](docs/Sweetalert.md)Toastrtoastr-[read](docs/Toastr.md)Full installation
-----------------

[](#full-installation)

Add

```
"sankaest/yii2-notification": "*",
"bower-asset/bootstrap-sweetalert": "^1.0",
"bower-asset/igrowl": "*",
"bower-asset/jqnotifybar": "^1.5",
"bower-asset/jquery-growl": "^1.3",
"bower-asset/jquery.notify": "^1.0",
"bower-asset/jquery-toast-plugin": "*",
"bower-asset/jquery.toaster": "*",
"bower-asset/lobibox": "*",
"bower-asset/notie": "^3.2",
"bower-asset/notifit": "^1.1",
"bower-asset/notific8": "^3.5",
"bower-asset/notifyjs": "^0.4",
"bower-asset/pnotify": "^3.0",
"bower-asset/noty": "^2.3",
"bower-asset/remarkable-bootstrap-notify": "^3.1",
"bower-asset/sweetalert": "^1.1",
"bower-asset/toastr": "^2.1"
```

to the `require` section of your `composer.json` file.

License
-------

[](#license)

Yii2-notification-wrapper is released under the MIT License. See the bundled [LICENSE.md](LICENSE.md)for details.

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity55

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

Every ~6 days

Total

2

Last Release

2014d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/826d3c778d6839730cf4eda440955d48d4eea30a52a06e16791636809df5f5a1?d=identicon)[sankaest](/maintainers/sankaest)

---

Top Contributors

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

---

Tags

notificationyii2moduleflashalertgrowltoastrtoastnotysweetalertnotyjsnotyfypnotyfynotific8lobibox

### Embed Badge

![Health badge](/badges/sankaest-yii2-notification/health.svg)

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

###  Alternatives

[loveorigami/yii2-notification-wrapper

This module for renders a message from session flash (with ajax, pjax support and etc.)

77199.7k5](/packages/loveorigami-yii2-notification-wrapper)[kartik-v/yii2-widget-growl

A widget to generate growl based notifications using bootstrap-growl plugin (sub repo split from yii2-widgets)

384.2M14](/packages/kartik-v-yii2-widget-growl)[kartik-v/yii2-widget-alert

A widget to generate alert based notifications using bootstrap-alert plugin (sub repo split from yii2-widgets)

284.1M24](/packages/kartik-v-yii2-widget-alert)[diecoding/yii2-toastr

Simple flash toastr notifications for Yii2

1328.8k](/packages/diecoding-yii2-toastr)[machour/yii2-notifications

Notifications for your Yii2 app

9135.7k](/packages/machour-yii2-notifications)[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.

1486.3k](/packages/odaialali-yii2-toastr)

PHPackages © 2026

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