Laravel-except-notify – Supports laravel exception notification of multiple channels (Bark, Chanify, Dingpin group robot, Feishubot, mail, Server sauce, enterprise wechat group robot, Xizhi).

Features (2.x Rebuilt version)

  • The laravel application is abnormal
  • Support a variety of channels (Bark, Chanify, Dingduo group robot, Feishu group robot, mail, Server sauce, enterprise wechat group robot, Xizhi)
  • Support for extended custom channels
  • Support for custom data collectors
  • Support for custom data converters

The installation

$composer require guanguans/laravel-exception-notify:^2.0 -vCopy the code

configuration

The registration service

laravel

$ php artisan vendor:publish --provider="Guanguans\\LaravelExceptionNotify\\ExceptionNotifyServiceProvider"
Copy the code

lumen

Add the following code snippet to the Register Service Providers section of the bootstrap/app.php file:

$app->register(\Guanguans\LaravelExceptionNotify\ExceptionNotifyServiceProvider::class);
$app->boot(\Guanguans\LaravelExceptionNotify\ExceptionNotifyServiceProvider::class);
Copy the code

Apply for channel tokens and other information

  • Bark
  • Chanify
  • Spike swarm robots
  • Flying book swarm robot
  • Server sauce
  • Enterprise wechat group robot
  • Interest to know

The token information is configured in the configuration file

config/exception-notify.php

Env file

EXCEPTION_NOTIFY_DEFAULT_CHANNEL=dingTalk
EXCEPTION_NOTIFY_DINGTALK_KEYWORD=keyword
EXCEPTION_NOTIFY_DINGTALK_TOKEN=c44fec1ddaa8a833156efb77b7865d62ae13775418030d94d
EXCEPTION_NOTIFY_DINGTALK_SECRET=SECc32bb7345c0f73da2b9786f0f7dd5083bd768a29b82
Copy the code

use

app/Exceptions/Handler.phpreportMethod to add

public function report(Exception $e)
{
    // The default channel
    \ExceptionNotifier::reportIf($this->shouldReport($e), $e);
    // Specify a channel
    \ExceptionNotifier::onChannel('dingTalk'.'mail')->reportIf($this->shouldReport($e), $e);

    parent::report($e);
}
Copy the code

Notice the results

Extend custom channels

App/will/AppServiceProvider. Add PHP boot method

public function boot()
{
    // Extend custom channels
    \ExceptionNotifier::extend('YourChannel'.function (\Illuminate\Contracts\Container\Container $container){
        // Returns an instance of \Guanguans\LaravelExceptionNotify\Contracts\Channel
    });
}
Copy the code