bezhanSalleh / filament-exceptions

A Simple & Beautiful Pluggable Exception Viewer for FilamentPHP's Admin Panel
MIT License
143 stars 22 forks source link

Guidance needed, how to install for Laravel 11? #61

Closed FrazeColder closed 2 weeks ago

FrazeColder commented 4 weeks ago

Hey there,

I am using Laravel 11. Laravel 11 does not have a app/Exceptions/Handler.php by default. Therefore, I have created this one:

<?php

namespace App\Exceptions;

use BezhanSalleh\FilamentExceptions\FilamentExceptions;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Illuminate\Support\Facades\Log;
use Throwable;

class Handler extends ExceptionHandler
{
    /**
     * The list of the inputs that are never flashed to the session on validation exceptions.
     *
     * @var array<int, string>
     */
    protected $dontFlash = [
        'current_password',
        'password',
        'password_confirmation',
    ];

    /**
     * Register the exception handling callbacks for the application.
     */
    public function register(): void
    {
        $this->reportable(function (Throwable $e) {
            Log::info("I got logged");
            FilamentExceptions::report($e);
        });
    }
}

However, the exceptions are not being logged and also the Log::info("I got logged"); did not log anything. Why are my exceptions not being logged? What am I doing wrong here?

Kind regards

schroeder-hesel commented 2 weeks ago

Hey, just add this to your bootstrap/app.php :

->withExceptions(function (Exceptions $exceptions) {
    $exceptions->report(function (Throwable $e) {
        FilamentExceptions::report($e);
    });
})
FrazeColder commented 2 weeks ago

Thank you!