laravel-exception-notify - 支援多種通道的 laravel 異常監控通知

guanguans發表於2021-07-06

laravel-exception-notify - 支援多種通道的 laravel 異常監控通知(釘釘群機器人、飛書群機器人、Server 醬、企業微信群機器人、息知)。

功能

  • 監控傳送 laravel 應用異常
  • 支援多種通道(釘釘群機器人、飛書群機器人、Server 醬、企業微信群機器人、息知)
  • 自定義傳送的異常資訊資料

原始碼

相關專案

環境要求

  • laravel >= 5.5

安裝

$ composer require guanguans/laravel-exception-notify -vvv

配置

釋出服務

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

申請通道 token 等資訊

配置檔案中配置 token 等資訊

config/exception-notify.php

使用

修改 app/Exceptions/Handler.php 檔案中的 report 方法

public function report(Exception $exception)
{
    // 新增的程式碼
    $this->shouldReport($exception) and \ExceptionNotifier::report($exception);
    // // 或者
    // $this->shouldReport($exception) and app('exception.notifier')->report($exception);
    // // 或者
    // $this->shouldReport($exception) and \Guanguans\LaravelExceptionNotify\Facades\Notifier::report($exception);

    parent::report($exception);
}

通知結果

本作品採用《CC 協議》,轉載必須註明作者和本文連結
No practice, no gain in one's wit. 我的 Gitub

相關文章