guanguans/laravel-exception-notify

监控异常并将报告发送到通知渠道(Dump、Log、Mail、AnPush、Bark、Chanify、DingTalk、Discord、Gitter、GoogleChat、IGot、Lark、Mattermost、MicrosoftTeams、NowPush、Ntfy、Push、Pushback、PushBullet、PushDeer、Pushover、PushPlus、QQ、RocketChat、ServerChan、ShowdocPush、SimplePush、Slack、Telegram、WeWork、WPu


README

监控异常并将报告发送到通知渠道(Dump、Log、Mail、AnPush、Bark、Chanify、DingTalk、Discord、Gitter、GoogleChat、IGot、Lark、Mattermost、MicrosoftTeams、NowPush、Ntfy、Push、Pushback、PushBullet、PushDeer、Pushover、PushPlus、QQ、RocketChat、ServerChan、ShowdocPush、SimplePush、Slack、Telegram、WeWork、WPush、XiZhi、YiFengChuanHua、Zulip)。

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

功能

  • 监控异常并将报告发送到通知渠道
  • 支持扩展自定义渠道
  • 支持通知速率限制
  • 支持自定义数据管道
  • 支持自定义数据收集器

相关链接

要求

  • PHP >= 7.4

安装

composer require guanguans/laravel-exception-notify --ansi -v

配置

发布文件(可选)

php artisan vendor:publish --provider="Guanguans\\LaravelExceptionNotify\\ExceptionNotifyServiceProvider" --ansi -v

申请渠道认证和其他信息

  • 通知
  • Dump(用于调试异常消息)
  • 日志
  • 邮件

config/exception-notify.php.env 文件中配置渠道

# EXCEPTION_NOTIFY_DEFAULTS=dingTalk,lark,mail,slack,telegram,...
EXCEPTION_NOTIFY_DEFAULTS=log,slack,weWork
EXCEPTION_NOTIFY_SLACK_WEBHOOK=https://hooks.slack.com/services/TPU9A9/B038KNUC0GY/6pKH3vfa3mjlUPcgLSjzR
EXCEPTION_NOTIFY_WEWORK_TOKEN=73a3d5a3-ceff-4da8-bcf3-ff5891778

用法

测试异常通知

php artisan exception-notify:test --ansi -v

通知示例

跳过报告

修改 app/Providers/AppServiceProvider.php 文件中的 boot 方法

<?php

use Guanguans\LaravelExceptionNotify\Facades\ExceptionNotify;
use Illuminate\Support\Arr;

public function boot(): void
{
    ExceptionNotify::skipWhen(static fn (\Throwable $throwable) => Arr::first(
        [
            \Symfony\Component\HttpKernel\Exception\HttpException::class,
            \Illuminate\Http\Exceptions\HttpResponseException::class,
        ],
        static fn (string $exception): bool => $throwable instanceof $exception
    ));
}

自定义渠道

修改 app/Providers/AppServiceProvider.php 文件中的 boot 方法

<?php

use Guanguans\LaravelExceptionNotify\Contracts\Channel;
use Guanguans\LaravelExceptionNotify\Facades\ExceptionNotify;
use Illuminate\Container\Container;

public function boot(): void
{
    ExceptionNotify::extend('YourChannelName', function (Container $container): Channel {
        return 'Instance of the `\Guanguans\LaravelExceptionNotify\Contracts\Channel`.';
    });
}

测试

composer test

变更日志

请参阅 CHANGELOG 以获取有关最近更改的更多信息。

贡献

请参阅 CONTRIBUTING 以获取详细信息。

安全漏洞

请参阅 我们的安全策略 了解如何报告安全漏洞。

鸣谢

感谢

许可

MIT 许可证(MIT)。请参阅 许可文件 以获取更多信息。