guanguans/laravel-exception-notify

Exception monitoring alarm notification in Laravel(Bark、Chanify、DingTalk、Discord、FeiShu、Mail、PushDeer、QQ Channel Bot、ServerChan、Slack、Telegram、WeWork、XiZhi).


README

简体中文 | ENGLISH

Exception monitoring alarm notification in Laravel(Bark、Chanify、DingTalk、Discord、FeiShu、Mail、PushDeer、QQ Channel Bot、ServerChan、Slack、Telegram、WeWork、XiZhi).

tests check & fix styling codecov Latest Stable Version GitHub release (with filter) Total Downloads License

Feature

  • Monitor and send laravel application exception
  • Support for multi-channel notification
  • Support for extending custom channel
  • Support for custom data collector
  • Support for custom data pipe
  • Support for notification rate limiting

Related Links

Requirement

  • PHP >= 7.4

Installation

composer require guanguans/laravel-exception-notify -v

Configuration

Register 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 as follows:

$app->register(\Guanguans\LaravelExceptionNotify\ExceptionNotifyServiceProvider::class);

Apply for channel token or secret information

Configure channels in the config/exception-notify.php or .env file

EXCEPTION_NOTIFY_DEFAULTS=dingTalk,log,...

EXCEPTION_NOTIFY_DINGTALK_KEYWORD=keyword # optional
EXCEPTION_NOTIFY_DINGTALK_TOKEN=c44fec1ddaa8a833156efb77b7865d62ae13775418030d94d
EXCEPTION_NOTIFY_DINGTALK_SECRET=SECc32bb7345c0f73da2b9786f0f7dd5083bd768a29b82 # optional

Laravel7 and below versions and lumen need to be added to the report method of app/Exceptions/Handler.php

public function report(Throwable $exception)
{
    \Guanguans\LaravelExceptionNotify\Facades\ExceptionNotify::reportIf($this->shouldReport($exception), $exception);

    parent::report($exception);
}

Usage

Test for exception notify

php artisan exception-notify:test

Notification example(Xi Zhi)

1 2 3
xiZhi-1 xiZhi-2 xiZhi-3

Extend custom channel

Modify the boot method in the app/Providers/AppServiceProvider.php file

public function boot()
{
    \ExceptionNotifier::extend('YourChannel', function (\Illuminate\Contracts\Container\Container $container){
        // return instance of the `\Guanguans\LaravelExceptionNotify\Contracts\ChannelContract`.          
    });
}

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

Thanks

License

The MIT License (MIT). Please see License File for more information.