gbuckingham89/laraflash
Composer 安装命令:
composer require gbuckingham89/laraflash
包简介
A package for handling flash messages / notifications in Laravel.
README 文档
README
A simple package for handling flash messages / notifications in Laravel. Written to suit my needs - but hopefully someone else will find it useful too.
The current version requires Laravel 7.0 & PHP 8.0 or greater. If you have a project that requires a lower version of PHP or Laravel, check the requirements of the older releases.
Installation
The recommended way is using Composer - simply run this command in your terminal:
composer require gbuckingham89/laraflash
The service provider and facade will be automatically registered for you unless you have disabled auto discovery. If this is the case, you'll need to manually register the service provider and facade:
For the service provider, add the following to the providers array in your app.php config file:
Gbuckingham89\Laraflash\ServiceProvider::class
For the facade, add the following to the aliases array in your app.php config file:
'Laraflash' => Gbuckingham89\Laraflash\Facade\Laraflash::class
Finally, you'll need to publish the view file (unless you want to roll your own). Do this by running this command in your terminal:
php artisan vendor:publish --provider="Gbuckingham89\Laraflash\ServiceProvider"
Use
Setting a message
Before you redirect to another page, simply use the Laraflash facade to set your message. You can call the main flash method as follows:
Laraflash::flash("This is a flash message.", "success");
The first parameter is your message, the second is the priority level.
There are also four helper methods available for easier setting of priority levels:
Laraflash::success("This is a success flash message."); Laraflash::info("This is an info flash message."); Laraflash::warning("This is a warning flash message."); Laraflash::danger("This is a danger flash message.");
Displaying the message
To display the message, simply include the bundled view (built for Bootstrap) in your view:
@include('laraflash::laraflash')
Alternatively, you can access the data in the session directly (stored in laraflash.message and laraflash.level) and roll your own view.
Testing Assertions
This package provides Gbuckingham89\Laraflash\LaraflashAssertions with some basic/common assertions if you have to test that your responses contain a laraflash message, or not.
use Gbuckingham89\Laraflash\LaraflashAssertions; LaraflashAssertions::assertResponseDoesntHaveLaraflash($response); LaraflashAssertions::assertResponseHasLaraflash($response, 'info', 'The message you are expecting'); LaraflashAssertions::assertResponseHasLaraflashSuccess($response, 'The message you are expecting'); LaraflashAssertions::assertResponseHasLaraflashInfo($response, 'The message you are expecting'); LaraflashAssertions::assertResponseHasLaraflashWarning($response, 'The message you are expecting'); LaraflashAssertions::assertResponseHasLaraflashDanger($response, 'The message you are expecting');
Copyright and license
Code and documentation copyright George Buckingham.
Code released under the MIT License.
gbuckingham89/laraflash 适用场景与选型建议
gbuckingham89/laraflash 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 46.81k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2017 年 01 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「notifications」 「flash」 「laravel」 「messages」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 gbuckingham89/laraflash 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 gbuckingham89/laraflash 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 gbuckingham89/laraflash 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Laravel Nova package that adds a notification feed in your Nova app.
Notification component for storing and retrieving flash data.
Shim repository for WebcamJS
Captures outgoing SMS notifications
A modern take on PHP session-based flash messages
A Laravel package made for displaying flashes messages in a conveniant way
统计信息
- 总下载量: 46.81k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 33
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-01-18