Eugenio Goryaev
Desarrollo, soporte y optimización

floor12/yii2-notification Creating notifications in browser with queue and JS and PHP-api

Latest Stable Version Scrutinizer Code Quality Latest Unstable Version Total Downloads License

This simple extension helps to show nice notifications in the browser. It uses SVG icons and can be customized by overwriting base CSS styles.

Try create notification by pressing this buttons:



Just run:

$ composer require floor12/yii2-notification

or add this to the require section of your composer.json.

"floor12/yii2-notification": "dev-master"

To include js and css files, add floor12\notification\NotificationAsset as dependency in your AppAsset:

use floor12\notification\NotificationAsset;
use yii\web\AssetBundle;

class AppAsset extends AssetBundle
    public $depends = [

Using as JS

To show notification in browser just pass message text to one of the f12notification object methods:;    //information message;
f12notification.success(text); //success message;
f12notification.error(text);   //error message;

For example:

if (userSucces == true)
  f12notification.success('Registration success'.)
  f12notification.error('Registration failed.')

Using as PHP

It's also possible to show notifications by passing message text to one of the floor12\notification\Notification methods:

use floor12\notification\Notification;

Notification::info('The form is loading...');
Notification::error('Pleas fill all required fields');
Notification::success('This model is saved');

In case if using PHP API, NotificationAsset will be included in your app by the Notification class.