承接 odaialali/yii2-toastr 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

odaialali/yii2-toastr

最新稳定版本:1.0b

Composer 安装命令:

composer require odaialali/yii2-toastr

包简介

This is the Toastr extension for Yii 2. It encapsulates Toastr plugin in terms of Yii widgets, and makes ajax notification easy to implement.

README 文档

README

This is the Toastr extension for Yii 2. It encapsulates Toastr plugin in terms of Yii widgets, and makes ajax notification easy to implement.

Installation

The preferred way to install this extension is through composer.

Either run

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

or add

"odaialali/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 :

<?= \odaialali\yii2toastr\Toastr::widget([ 'toastType' => 'error', 'message' => 'This is an error.', 'customStyle' => false ]);?>

There are 2 main useful widgets

ToastrFlash

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"); ?>
<?= \odaialali\yii2toastr\ToastrFlash::widget([ 'options' => [ 'positionClass' => 'toast-bottom-left' ] ]);?>

ToastrAjaxFeed

fetch notification from ajax url

<?= \odaialali\yii2toastr\ToastrAjaxFeed::widget([ 'feedUrl' => yii\helpers\Url::toRoute('/user/profile/notification-feed'), 'interval' => 5000, 'options' => [ 'positionClass' => 'toast-bottom-left' ] ]);?>

the ajax controller should return an array like this

public function actionNotificationFeed(){ $ret = [ [ 'type' => 'error', 'message' => 'error message', 'title' => 'Hey!' ], [ 'type' => 'info', 'message' => 'another message', 'title' => 'Hello' ] ]; return \yii\helpers\Json::encode($ret); }

统计信息

  • 总下载量: 83.4k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 16
  • 点击次数: 3
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 14
  • Watchers: 2
  • Forks: 11
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固