mirzabusatlic / laravel-exceptions
此包已被废弃且不再维护。未建议替代包。
在数据库表中跟踪异常
此包尚无发布版本,信息不多。
README
Laravel/Lumen的异常跟踪
安装
composer require mirzabusatlic/laravel-exceptions- 将
Busatlic\Laravel\Exceptions\ExceptionsServiceProvider添加到您的config/app.php。 - 运行
php artisan vendor:publish --provider=Busatlic\\Laravel\\Exceptions\\ExceptionsServiceProvider以生成创建异常表的迁移 - 运行
php artisan migrate以创建异常表
使用
在您的Exceptions\Handler.php中,包含ReportsExceptions特质,然后使用reportException方法报告异常,如下所示
namespace App\Exceptions; use Busatlic\Laravel\Exceptions\ReportsExceptions; use Exception; use Illuminate\Validation\ValidationException; use Illuminate\Auth\Access\AuthorizationException; use Illuminate\Database\Eloquent\ModelNotFoundException; use Symfony\Component\HttpKernel\Exception\HttpException; use Laravel\Lumen\Exceptions\Handler as ExceptionHandler; class Handler extends ExceptionHandler { use ReportsExceptions; /** * A list of the exception types that should not be reported. * * @var array */ protected $dontReport = [ AuthorizationException::class, HttpException::class, ModelNotFoundException::class, ValidationException::class, ]; /** * Report or log an exception. * * This is a great spot to send exceptions to Sentry, Bugsnag, etc. * * @param \Exception $e * @return void */ public function report(Exception $e) { parent::report($e); $this->reportException($e, $this->shouldReport($e)); } /** * Render an exception into an HTTP response. * * @param \Illuminate\Http\Request $request * @param \Exception $e * @return \Illuminate\Http\Response */ public function render($request, Exception $e) { return parent::render($request, $e); } }