lavrentiev/yii2-toastr
最新稳定版本:2.0.2
Composer 安装命令:
composer require lavrentiev/yii2-toastr
包简介
Simple javascript toast notifications
README 文档
README
Simple javascript toast notifications - Javascript library for non-blocking notifications. jQuery is required. The goal is to create a simple core library that can be customized and extended.
Установка
Расширение устанавливается с помощью Composer интсрукция по установке Composer
Установка расширения через Composer, выполнить следующую команду:
composer require --prefer-dist lavrentiev/yii2-toastr или (master)
composer require --prefer-dist lavrentiev/yii2-toastr "dev-master" или внести изменения в секцию require в composer.json и выполнить composer update
"lavrentiev/yii2-toastr": "^2.0" или (master)
"lavrentiev/yii2-toastr": "dev-master" Уведомления Notification::widget()
use lavrentiev\widgets\toastr\Notification; Notification::widget([ 'type' => 'info', 'title' => 'Toast Notifications', 'message' => 'Simple javascript toast notifications' ]); Notification::widget([ 'type' => 'error', 'title' => 'Toast Notifications', 'message' => 'Simple javascript toast notifications' ]); Notification::widget([ 'type' => 'success', 'title' => 'Toast Notifications', 'message' => 'Simple javascript toast notifications' ]); Notification::widget([ 'type' => 'warning', 'title' => 'Toast Notifications', 'message' => 'Simple javascript toast notifications' ]); Notification::widget([ 'type' => 'info', 'message' => 'Simple javascript toast notifications' ]); Notification::widget([ 'type' => 'error', 'message' => 'Simple javascript toast notifications' ]); Notification::widget([ 'type' => 'success', 'message' => 'Simple javascript toast notifications' ]); Notification::widget([ 'type' => 'warning', 'message' => 'Simple javascript toast notifications' ]);
Также присутствует возможность настройки произвольного уведомления, по параметрам предусмотренным разработчиками Toastr by CodeSeven
Notification::widget([ 'type' => Notification::TYPE_ERROR, 'title' => 'Toast Notifications', 'message' => 'Simple javascript toast notifications', 'options' => [ "closeButton" => false, "debug" => false, "newestOnTop" => false, "progressBar" => false, "positionClass" => Notification::POSITION_TOP_RIGHT, "preventDuplicates" => false, "onclick" => null, "showDuration" => "300", "hideDuration" => "1000", "timeOut" => "5000", "extendedTimeOut" => "1000", "showEasing" => "swing", "hideEasing" => "linear", "showMethod" => "fadeIn", "hideMethod" => "fadeOut" ] ]);
Уведомления NotificationFlash::widget()
Подключение осуществляеться глобально допустим в layouts проекта.
<?= \lavrentiev\widgets\toastr\NotificationFlash::widget() ?>
Также присутствует возможность настройки уведомлений, по параметрам предусмотренным разработчиками Toastr by CodeSeven
<?= \lavrentiev\widgets\toastr\NotificationFlash::widget([ 'options' => [ "closeButton" => true, "debug" => false, "newestOnTop" => false, "progressBar" => false, "positionClass" => \lavrentiev\widgets\toastr\NotificationFlash::POSITION_TOP_RIGHT, "preventDuplicates" => false, "onclick" => null, "showDuration" => "300", "hideDuration" => "1000", "timeOut" => "5000", "extendedTimeOut" => "1000", "showEasing" => "swing", "hideEasing" => "linear", "showMethod" => "fadeIn", "hideMethod" => "fadeOut" ] ]) ?>
\Yii::$app->session->setFlash('error', 'This is the message'); \Yii::$app->session->setFlash('success', 'This is the message'); \Yii::$app->session->setFlash('info', 'This is the message'); \Yii::$app->session->setFlash('warning', 'This is the message');
\Yii::$app->session->setFlash('warning', ['Error 1', 'Error 2', 'Error 3']); \Yii::$app->session->setFlash('success', ['Error 1', 'Error 2', 'Error 3']);
Допустимые параметры
| Параметр | Значение по умолчанию | Допустимые значения | Описание |
|---|---|---|---|
| type | info | info, error, success, warning | Тип уведомления |
| title | --- | --- | Заголовок уведомления |
| message | Simple javascript toast notifications | --- | Текст уведомления |
| options | [] | Подробней... | Дополнительные опции |
Допустимые константы типов:
TYPE_INFO = 'info' TYPE_ERROR = 'error' TYPE_SUCCESS = 'success' TYPE_WARNING = 'warning' Допустимые константы положения:
POSITION_TOP_RIGHT = 'toast-top-right'; POSITION_TOP_LEFT = 'toast-top-left'; POSITION_TOP_CENTER = 'toast-top-center'; POSITION_TOP_FULL_WIDTH = 'toast-top-full-width'; POSITION_BOTTOM_RIGHT = 'toast-bottom-right'; POSITION_BOTTOM_LEFT = 'toast-bottom-left'; POSITION_BOTTOM_CENTER = 'toast-bottom-center'; POSITION_BOTTOM_FULL_WIDTH = 'toast-bottom-full-width'; Демонстрация
- Demo can be found at http://codeseven.github.io/toastr/demo.html
Дополнительно
lavrentiev/yii2-toastr 适用场景与选型建议
lavrentiev/yii2-toastr 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 103.61k 次下载、GitHub Stars 达 24, 最近一次更新时间为 2026 年 01 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「jquery」 「extension」 「notification」 「yii2」 「toastr」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 lavrentiev/yii2-toastr 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 lavrentiev/yii2-toastr 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 lavrentiev/yii2-toastr 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
This package makes it easy to send notifications via AfricasTalking with Laravel
A custom URL rule class for Yii 2 which allows to create translated URL rules
Yii2 LightBox image galary widget uses Lightbox v2.10.0 by Lokesh Dhakar
The Yii2 extension uses jQuery jquery.carousel-1.1.min.js and makes image carousel from php array of structure defined.
TYPO3 CMS extension to create gallery content element with preset crop ratios and pagination
UI Kit 3 Extension for Yii2
统计信息
- 总下载量: 103.61k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 24
- 点击次数: 28
- 依赖项目数: 4
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2026-01-04



