smodav/flash
Composer 安装命令:
composer require smodav/flash
包简介
Flash messaging package for use with laravel
README 文档
README
This is a laravel package for displaying flash notifications that extends Sweet Alert and provides an extra custom notice notification on the top left.
Installation
Pull in the package through Composer.
Run composer require smodav/flash
When using Laravel 5, include the service provider and its alias within your config/app.php.
'providers' => [ SmoDav\Flash\FlashServiceProvider::class, ]; 'aliases' => [ 'Flash' => SmoDav\Flash\Flash::class, ];
Publish the package specific assets and view using
php artisan vendor:publish
This will publish the flash view into resources/views/vendor/smodav/flash/ directory and also its accompanying css and javascript files into their respective resources/assets/ directory.
Usage
The package comes with a helper function flash() and its respective facade Flash. Within your controllers or closures, use either before a redirect:
public function delete() { flash()->success('Users', 'Successfully banned user.'); return redirect()->route('users.index'); } // OR public function delete() { Flash::success('Users', 'Successfully banned user.'); return redirect()->route('users.index'); }
If you would like the notification to persist till dismissed by the user, use the persist() method on the instance:
public function delete() { Flash::success('Users', 'Successfully banned user.')->persist(); return redirect()->route('users.index'); }
The package has allows you to send different types of flash alerts:
Flash::info('Title', 'Message')Flash::success('Title', 'Message')Flash::error('Title', 'Message')Flash::warning('Title', 'Message')
All the above can be persisted using persist().
An additional notice() is included that provides a notice on the top right edge, however, the notice cannot be persisted:
Flash::notice('Message')
public function delete() { Flash::notice('Successfully banned user.'); return redirect()->route('users.index'); }
For a basic flash instance of type info, just use the flash helper function:
flash(Title, Message)
When using Laravel, this package creates flash session keys:
Alerts
sf_titlecontaining the title of the flash message.sf_messagecontaining the actual flash message.sf_levelcontaining the level of flash message.sf_persistonly present when persist is used.
Notices
sf_notice_messagecontaining the flash notice message.
Within your views, include the flash view and the corresponding css and javascript files. You may modify the flash view and add more functionality to the flash instances by passing the properties described in Sweet Alert to the sflash instance:
sflash({
title: "{{ session('sf_title') }}",
text: "{{ session('sf_message') }}",
type: "{{ session('sf_level') }}",
allowOutsideClick: true,
confirmButtonText: "Okay Man",
showConfirmButton: true
});
smodav/flash 适用场景与选型建议
smodav/flash 是一款 基于 CSS 开发的 Composer 扩展包,目前已累计 262 次下载、GitHub Stars 达 3, 最近一次更新时间为 2016 年 06 月 15 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「flash」 「laravel」 「alert」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 smodav/flash 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 smodav/flash 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 smodav/flash 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Notification component for storing and retrieving flash data.
Shim repository for WebcamJS
A modern take on PHP session-based flash messages
A Laravel package made for displaying flashes messages in a conveniant way
Yii bot for sending messages (alerts) to Slack
Alfabank REST API integration
统计信息
- 总下载量: 262
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 12
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-06-15