viecngay / lara-except-notify
当应用程序出现异常时进行通知
1.0.2
2019-02-13 08:41 UTC
Requires
- php: >=5.6.4
- guzzlehttp/guzzle: ^6.3
- laravel/framework: >=5.4.0
This package is auto-updated.
Last update: 2024-09-13 21:29:27 UTC
README
当您的项目出现异常时通知您的Slack频道
需求
- laravel >= 5.4
用法
步骤 1:在您的项目中添加依赖项 通过composer添加您的项目
composer require viecngay/lara-except-notify
步骤 2:注册服务提供者 如果您使用laravel 5.4,您必须打开 config/app.php
并添加提供者
'providers' => [ ... ViecNgay\Laraexcepnotify\ServiceProvider::class, ]
如果您使用laravel 5.5或更高版本,请跳过此步骤。前往步骤 3
步骤 3:发布供应商
php artisan vendor:publish --provider="ViecNgay\Laraexcepnotify\ServiceProvider"
步骤 4:配置您的频道
打开 config/notification.php
,您将看到
<?php return [ 'lara_exception_notify' => [ // allow true or false // true is enable notify when have exception // false is disable notify 'enable' => true, // The channel you want to nofity 'channel' => ['slack'], // Your slack web hook // more information about slack web hook: https://api.slack.com/incoming-webhooks 'slack_web_hook_url' => '' ] ];
步骤 4:添加事件
打开 app/Exceptions/Handler.php
并进入 report
动作,更改为
// use ViecNgay\Laraexcepnotify\Events\HasExceptionEvent; public function report(Exception $exception) { parent::report($exception); if ($this->shouldReport($exception)) { event(new HasExceptionEvent($exception)); } }