open-admin-ext/reporter

laravel的异常报告器

dev-main 2022-06-28 17:27 UTC

This package is auto-updated.

Last update: 2024-08-28 23:04:38 UTC


README

此工具将异常信息存储到数据库中,并为开发者提供友好的Web界面来查看异常信息。

StyleCI Packagist Total Downloads Pull request welcome

截图

open-admin-reporter

安装

$ composer require open-admin-ext/reporter

$ php artisan vendor:publish --tag=open-admin-reporter

$ php artisan migrate --path=vendor/open-admin-ext/reporter/database/migrations

$ php artisan admin:import reporter

打开 app/Exceptions/Handler.php,

  1. 添加: use OpenAdmin\Admin\Reporter\Reporter;
  2. register ... reportable 方法内调用 Reporter::report()
<?php

namespace App\Exceptions;

use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use OpenAdmin\Admin\Reporter\Reporter;
use Throwable;


class Handler extends ExceptionHandler
{
    /**
     * A list of the exception types that are not reported.
     *
     * @var array
     */
    protected $dontReport = [
        //
    ];

    /**
     * A list of the inputs that are never flashed for validation exceptions.
     *
     * @var array
     */
    protected $dontFlash = [
        'current_password',
        'password',
        'password_confirmation',
    ];

    /**
     * Register the exception handling callbacks for the application.
     *
     * @return void
     */
    public function register()
    {
        $this->reportable(function (Throwable $e) {
            // Add This line
            Reporter::report($e);
        });
    }
}

打开 https:///admin/exceptions 来查看异常。

许可证

许可协议为 MIT许可证 (MIT).