This is the Toastr extension for Yii 2. It encapsulates Toastr plugin in terms of Yii widgets.
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.
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
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'
]
]);?>