kallbuloso/notify
Composer 安装命令:
composer require kallbuloso/notify
包简介
toastr.js, pnotify.js flush notifications for Laravel 5, 6, 7 and Lumen
关键字:
README 文档
README
👀 This package helps you to add notifications to your Laravel 5 and Lumen projects.
Install
You can install the package using composer
$ composer require kallbuloso/notify
Then add the service provider to config/app.php. In Laravel versions 5.5 and beyond, this step can be skipped if package auto-discovery is enabled.
'providers' => [ ... kallbuloso\Notify\NotifyServiceProvider::class ... ];
As optional if you want to modify the default configuration, you can publish the configuration file:
$ php artisan vendor:publish --provider='kallbuloso\Notify\NotifyServiceProvider' --tag="config"
For Lumen :
- In
bootstrap/app.php- uncomment
$app->withFacades(); - add bindings for ToastrServiceProvider :
$app->register(kallbuloso\Notify\NotifyServiceProvider::class);
- uncomment
- Add
config/session.php, since it is not present inLumenby default. You can takesession.phpfrom Laravel Official Repository
Usage:
Include jQuery and your notification plugin assets in your view template:
- Add your styles links tag or
@notify_css - Add your scripts links tags or
@notify_js - Add
@notify_renderto render your notification - use
notify()helper function inside your controller to set a toast notification for info, success, warning or error
// Display an info toast with no title notify()->info('Are you the 6 fingered man?')
as an example:
<?php namespace App\Http\Controllers; use App\Post; use App\Http\Requests\PostRequest; use Illuminate\Database\Eloquent\Model; class PostController extends Controller { public function store(PostRequest $request) { $post = Post::create($request->only(['title', 'body'])); if ($post instanceof Model) { notify()->success('Data has been saved successfully!'); return redirect()->route('posts.index'); } notify()->error('An error has occurred please try again later.'); return back(); } }
After that add the @notify_render at the bottom of your view to actualy render the notify notifications.
<!doctype html> <html> <head> <title>kallbuloso/toastr</title> @notify_css </head> <body> </body> @notify_js @notify_render </html>
Other Options
// Set a warning toast, with no title notify()->warning('My name is Inigo Montoya. You killed my father, prepare to die!') // Set a success toast, with a title notify()->success('Have fun storming the castle!', 'Miracle Max Says') // Set an error toast, with a title notify()->error('I do not think that word means what you think it means.', 'Inconceivable!') // Override global config options from 'config/notify.php' notify()->success('We do have the Kapua suite available.', 'Turtle Bay Resort', ['timeOut' => 5000]) // for pnotify driver notify()->alert('We do have the Kapua suite available.', 'Turtle Bay Resort', ['timeOut' => 5000])
other api methods:
// You can also chain multiple messages together using method chaining
notify()->info('Are you the 6 fingered man?')->success('Have fun storming the castle!')->warning('doritos');
configuration:
// config/notify.php <?php return [ 'default' => 'toastr', 'toastr' => [ 'class' => \kallbuloso\Notify\Notifiers\Toastr::class, 'notify_js' => [ 'https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js', 'https://cdnjs.cloudflare.com/ajax/libs/toastr.js/2.1.4/toastr.min.js', ], 'notify_css' => [ 'https://cdnjs.cloudflare.com/ajax/libs/toastr.js/2.1.4/toastr.min.css', ], 'types' => [ 'error', 'info', 'success', 'warning', ], 'options' => [], ], 'pnotify' => [ 'class' => \kallbuloso\Notify\Notifiers\Pnotify::class, 'notify_js' => [ 'https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js', 'https://cdnjs.cloudflare.com/ajax/libs/pnotify/3.2.1/pnotify.js', ], 'notify_css' => [ 'https://cdnjs.cloudflare.com/ajax/libs/pnotify/3.2.1/pnotify.css', 'https://cdnjs.cloudflare.com/ajax/libs/pnotify/3.2.1/pnotify.brighttheme.css', ], 'types' => [ 'alert', 'error', 'info', 'notice', 'success', ], 'options' => [], ], 'sweetalert2' => [ 'class' => \kallbuloso\Notify\Notifiers\SweetAlert2::class, 'notify_js' => [ 'https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js', 'https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/7.28.1/sweetalert2.min.js', 'https://cdn.jsdelivr.net/npm/promise-polyfill', ], 'notify_css' => [ 'https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/7.28.1/sweetalert2.min.css', ], 'types' => [ 'error', 'info', 'question', 'success', 'warning', ], 'options' => [], ], ];
Credits
License
MIT
kallbuloso/notify 适用场景与选型建议
kallbuloso/notify 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 14 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 04 月 28 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「alerts」 「notification」 「laravel」 「messages」 「flush」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 kallbuloso/notify 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 kallbuloso/notify 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 kallbuloso/notify 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
This package makes it easy to send notifications via AfricasTalking with Laravel
Apple Push Notification & Feedback Provider
Throttle notifications on a per-channel basis
Add visual alerts / warnings to Flarum posts
Laravel package for managing session messages and alerts in view responses
Extensible library for building notifications and sending them via different delivery channels.
统计信息
- 总下载量: 14
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 11
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-04-28
