laravel-exception-notify - laravel exception notification that supports multiple channels (Bark, Chanify, Dingding group robot, Feishu group robot, mail, Server sauce, enterprise WeChat group robot, information knowledge).
Features (2.x refactored version)
- Monitor sending laravel application exceptions
- Support multiple channels (Bark, Chanify, Dingding group robot, Feishu group robot, mail, Server sauce, enterprise WeChat group robot, information knowledge)
- Support for extended custom channels
- Support for custom data collectors
- Support for custom data converters
Install
$ composer require guanguans/laravel-exception-notify:^2.0 -v
configure
registration service
laravel
$ php artisan vendor:publish --provider="Guanguans\\LaravelExceptionNotify\\ExceptionNotifyServiceProvider"
lumen
Add the following snippet to the bootstrap/app.php
file under the Register Service Providers
section:
$app->register(\Guanguans\LaravelExceptionNotify\ExceptionNotifyServiceProvider::class);
$app->boot(\Guanguans\LaravelExceptionNotify\ExceptionNotifyServiceProvider::class);
Apply for relevant channel token and other information
Configure token and other information in the configuration file
config/exception-notify.php
.env
file configuration
EXCEPTION_NOTIFY_DEFAULT_CHANNEL=dingTalk
EXCEPTION_NOTIFY_DINGTALK_KEYWORD=keyword
EXCEPTION_NOTIFY_DINGTALK_TOKEN=c44fec1ddaa8a833156efb77b7865d62ae13775418030d94d
EXCEPTION_NOTIFY_DINGTALK_SECRET=SECc32bb7345c0f73da2b9786f0f7dd5083bd768a29b82
use
app/Exceptions/Handler.php
method report
added
public function report(Exception $e)
{
// 默认通道
\ExceptionNotifier::reportIf($this->shouldReport($e), $e);
// 指定通道
\ExceptionNotifier::onChannel('dingTalk', 'mail')->reportIf($this->shouldReport($e), $e);
parent::report($e);
}
notification result
Extend custom channel
app/Providers/AppServiceProvider.php
in boot
method of 0623008484f0d7
public function boot()
{
// 扩展自定义通道
\ExceptionNotifier::extend('YourChannel', function (\Illuminate\Contracts\Container\Container $container){
// 返回 \Guanguans\LaravelExceptionNotify\Contracts\Channel 的实例
});
}
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。