bupy7/yii2-snotify

This package is abandoned and no longer maintained. No replacement package was suggested.

Snotify is extension implements at server-side notification to the user without client-side.

Installs: 58

Dependents: 0

Suggesters: 0

Security: 0

Stars: 4

Watchers: 1

Forks: 2

Open Issues: 0

Type:yii2-extension

dev-master 2016-02-08 19:40 UTC

This package is auto-updated.

Last update: 2020-04-11 02:19:17 UTC


README

Snotify is extension implements at server-side notification to the user without client-side.

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist bupy7/yii2-snotify "*"

or add

"bupy7/yii2-snotify": "*"

to the require section of your composer.json file.

Usage

Register module to modules section in config file:

[
    'modules' => [
        ...
        
        'snotifymodule' => [
            'class' => 'bupy7\notify\ss\Module',
        ],

        ...
    ],
],

Add snotifymodule to bootstrap section in config file:

[
    'bootstrap' => [
        ...
        
        'snotifymodule',
    
        ...
    ],
],

Register manager of snotify to components section in config file:

[
    'components' => [
        ...

        'snotify' => [
            'class' => 'bupy7\notify\ss\components\Manager',
        ],
        
        ...
    ],
],

You can rename a component and a module how do you like.

Run migration:

php ./yii migrate/up --migrationPath=@bupy7/notify/ss/migrations

Adding notification message:

$userId = Yii::$app->user->id;
$body = 'Example of text message';
$title = 'Example of title message';
Yii::$app->snotify
    // success notify type
    ->addSuccess($userId, $body, $title)
    // danger notify type
    ->addDanger($userId, $body, $title)
    // info notify type
    ->addInfo($userId, $body, $title)
    // warning notify type
    ->addWarning($userid, $body, $title);

Profit! Your notification added to {{%notification}} table.

Configuration

Module:

[
    'modules' => [
        ...
        
        'snotifymodule' => [
            'class' => 'bupy7\notify\ss\Module',
            'tableName' => '{{%notification}}', // table name with notification messages
            'db' => 'db', // database connection component config or name
        ],

        ...
    ],
],

License

yii2-snotify is released under the BSD 3-Clause License.