jalle19/laravel-unshitty-flash
Composer 安装命令:
composer require jalle19/laravel-unshitty-flash
包简介
Highly opinionated flash message service for Laravel
README 文档
README
Highly opinionated flash message service for Laravel. In contrast to practically all other similar libraries I've seen, this one:
- Supports multiple messages
- Supports multiple identical messages
- Supports flashing immediately, i.e. to the current request
- Let's you configure the session key used
- Forces you to inject the service, no magic facade
- Forces you to operate on the
Requestobject itself
Installation
Install the package:
composer require jalle19/laravel-unshitty-flash
Register the service provider:
'providers' => [ ... Jalle19\Laravel\UnshittyFlash\FlashServiceProvider::class, ... ]
Publish the configuration file:
php artisan vendor:publish --provider="Jalle19\Laravel\UnshittyFlash\FlashServiceProvider"
Usage
Inject FlashService into the controller you want to create flash messages from, then use it like this:
$this->flashService->success($request, 'Some successful message'); $this->flashService->info($request, 'Some informational message'); $this->flashService->warning($request, 'Some warning'); $this->flashService->danger($request, 'Some dangerous message');
If you need to flash a message to the current request, (e.g. from a middleware that displays a permanent message), pass
true as the third parameter:
$this->flashService->info($request, 'Permanently visible message', true);
If the message levels above are not enough for you, you can use an arbitrary level using the message() method:
$this->flashService->message($request, 'Some rant about libraries', 'rant');
To render the flash messages in your views, you can use something like the following snippet:
@foreach (session()->get(config('flash.session_key'), []) as $notification) <div class="alert alert-{{ $notification['level'] }} alert-dismissible in"> <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button> {!! $notification['message'] !!} </div> @endforeach
jalle19/laravel-unshitty-flash 适用场景与选型建议
jalle19/laravel-unshitty-flash 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 506 次下载、GitHub Stars 达 1, 最近一次更新时间为 2017 年 04 月 05 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 jalle19/laravel-unshitty-flash 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 jalle19/laravel-unshitty-flash 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 506
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 11
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-04-05