Skip to content

AlikDex/yii2-toastr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

yii2-toastr

Toastr notifications widget for yii2

This is the Toastr extension for Yii 2. It encapsulates Toastr plugin in terms of Yii widgets.

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist alikdex/yii2-toastr "*"

or add

"alikdex/yii2-toastr": "*"

to the require section of your composer.json file.

Usage

Once the extension is installed, you can test that the extension works by simply use it in your code by :

<?= \alikdex\toastr\Toastr::widget([
    'toastType' => 'error',
    'message' => 'This is an error.',
]);?>

There are 2 main useful widgets

ToastrAlert

displays Yii flash messages in toastr notification style

<?php
$session = \Yii::$app->getSession();
$session->setFlash('error', "msg1");
$session->setFlash('danger', "msg2");
$session->setFlash('warning', "msg3");
$session->setFlash('info', "msg4");
$session->setFlash('success', "msg5");
?>
<?= \alikdex\toastr\ToastrAlert::widget([
    'options' => [
        'positionClass' => 'toast-bottom-left'
    ]
]);?>

About

Toastr notifications widget for yii2

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages