Laravel错误声明App \ Exceptions \ Handler :: report(Throwable $ exception) [英] Laravel error Declaration of App\Exceptions\Handler::report(Throwable $exception)
问题描述
我正在使用Laravel 6,并在将其部署到运行PHP 7.3的共享主机时出现以下错误:
I'm using Laravel 6 and getting the following error when deploying to a shared host running PHP 7.3:
App\Exceptions\Handler::report(Throwable $exception)
App \ Exceptions \ Handler :: report(Throwable $ exception)声明必须与/home/kb2hm3y8r4wm/public_html/laravel.supremeanimation.com中的Illuminate \ Foundation \ Exceptions \ Handler :: report(Exception $ e)兼容/app/Exceptions/Handler.php在第8行
Declaration of App\Exceptions\Handler::report(Throwable $exception) must be compatible with Illuminate\Foundation\Exceptions\Handler::report(Exception $e) in /home/kb2hm3y8r4wm/public_html/laravel.supremeanimation.com/app/Exceptions/Handler.php on line 8
推荐答案
我认为您收到的错误是由于Laravel 7(而非6)上的更改所致,正如您在
I think the error you're getting is due to changes on Laravel 7 (not 6), as you can see on Laravel 7 upgrade guide. Check this:
-
对于Laravel<7:
For Laravel < 7:
应用程序的报告和呈现方法
App \ Exceptions \ Handler
类应接受的实例Exception
接口而不是Throwable
实例:
The report and render methods of your application's
App\Exceptions\Handler
class should accept instances of theException
interface instead ofThrowable
instances:
use Exception;
public function report(Exception $exception);
public function render($request, Exception $exception);
对于Laravel> = 7:
For Laravel >= 7:
应用程序的报告和呈现方法
App \ Exceptions \ Handler
类应接受的实例Throwable
接口,而不是Exception
实例:
The report and render methods of your application's
App\Exceptions\Handler
class should accept instances of theThrowable
interface instead ofException
instances:
use Throwable;
public function report(Throwable $exception);
public function render($request, Throwable $exception);
这篇关于Laravel错误声明App \ Exceptions \ Handler :: report(Throwable $ exception)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!