【Laravel】How to Fix 'Handler::report(Exception $exception) must be compatible with report(Throwable $e) in Handler.php on line 37'
Thank you for your continued support.
This article contains advertisements that help fund our operations.
Table Of Contents
This article explains how to fix the error 'Handler::report(Exception $exception) must be compatible with report(Throwable $e) in Handler.php on line 37' in Laravel.
Full Error Message
PHP Fatal error: Declaration of App\Exceptions\Handler::report(Exception $exception) must be compatible with Illuminate\Foundation\Exceptions\Handler::report(Throwable $e) in /var/www/html/app/Exceptions/Handler.php on line 37
This article summarizes how to resolve this error.
Solution
Up until Laravel 6, error handling used the Exception class, but starting from Laravel 7, the Throwable class is used instead.
Previously, the following was written:
report(Exception $exception)However, it has been changed to:
report(Throwable $e)From Laravel 7 onward, Throwable should be used.
This change was introduced because, starting from PHP 7, Throwable became the parent class of Exception.
By using Throwable, not only Exception but also Error can be properly caught, improving the flexibility of error handling.
In this case, you need to modify app/Exceptions/Handler.php as follows:
use Throwable; // Explicitly use Throwable
// Old version code (Laravel 6)
public function report(Exception $exception)
{
parent::report($exception);
}
// Fixed version (Laravel 7 and later)
public function report(Throwable $exception)
{
parent::report($exception);
}
// Also update the render method
public function render($request, Throwable $exception)
{
return parent::render($request, $exception);
}With these modifications, the error should be resolved.
I hope this helps someone.





