genealabs/laravel-messenger
Composer 安装命令:
composer require genealabs/laravel-messenger
包简介
Flash notification module for Laravel.
README 文档
README
Goal
To provide a drop-in, application-wide alerting functionality to display various types of alerts and notifications to the user in response to their actions.
Prerequisites
- Bootstrap 3 or 4
- Laravel 5.5 or 5.6
- PHP >= 7.1.3
Features
- Feedback notifications in form of bootstrap alerts or modals.
- Send notifications from facade, app IoC reference, or blade directive.
- Display notification easily via a blade command.
Installation
composer require genealabs/laravel-messenger
Nothing else needs to be done, as the service provider and facades will be auto-loaded.
Configuration
If you need to make changes to the default configuration, run the following
command to publish the configuration file config\genealabs-laravel-messenger.php:
php artisan messenger:publish --config
After that you can configure the configuration according to your needs:
/* |-------------------------------------------------------------------------- | CSS Framework Configuration |-------------------------------------------------------------------------- | | Here you may configure the CSS framework to be used by Messenger for | Laravel. This allows you to switch or upgrade frameworks without | having to recreate all your alerts. | | Available Settings: "bootstrap3", "bootstrap4" | */ 'framework' => 'bootstrap4', /* |-------------------------------------------------------------------------- | JavaScript Blade Section |-------------------------------------------------------------------------- | | Your layout blade template will need to have a section dedicated to | inline JavaScript methods and commands that are injected by this | package. This will eliminate conflicts with Vue, as well as | making sure that JS is run after all deps are loaded. | */ 'javascript-blade-section' => 'js',
Usage
- Trigger an alert using either the facade/IoC helper, or a blade directive in another view:
// IoC helper: app('messenger')->send('message', 'title', 'level', autoHide, 'framework'); // Facade: Messenger::send('message', 'title', 'level', autoHide, 'framework'); // Blade directive: @send ('message', 'title', 'level', autoHide, 'framework')
- Add the placeholder to your layout blade file:
<div class="container">
@deliver
</div>
Parameters
message
string|required
The body of the message you want to deliver to your user. This may contain HTML. If you add links, be sure to add the appropriate classes for the framework you are using.
title
string | optional | default: ''
Title of the notification, will be inserted as an <h4> tag, can also include
HTML. Again, keep in mind to add any framework-specific formatting yourself.
level
string | optional | default: 'info'
If provided, must be one of the following: 'info', 'success', 'warning', 'danger'.
autoHide
boolean | optional | default: false
Allows you to let the notification disappear automatically after 15 seconds. If autoHide is false, the user will be provided a close button in the alert.
framework
string | optional | default: 'bootstrap3'
Specify the framework you are using. Right now it only supports 'bootstrap3' or 'bootstrap4'.
type
string | optional | default: 'alert'
Invoke any of the available alert modes. Currently only supports 'alert' or 'modal'.
genealabs/laravel-messenger 适用场景与选型建议
genealabs/laravel-messenger 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 876 次下载、GitHub Stars 达 135, 最近一次更新时间为 2017 年 06 月 26 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 genealabs/laravel-messenger 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 genealabs/laravel-messenger 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 876
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 136
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-06-26