Handler.php 第 25 行中的 Laravel FatalErrorException

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/36983734/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 13:42:55  来源:igfitidea点击:

Laravel FatalErrorException in Handler.php line 25

phplaravel

提问by Miguel Stevens

I'm getting the following error on random occasions, working on a Laravel 5.1 project on the latest homestead with PHP7

我在随机情况下收到以下错误,在最新的 Homestead 上使用 PHP7 处理 Laravel 5.1 项目

FatalErrorException in Handler.php line 25:
Uncaught TypeError: Argument 1 passed to App\Exceptions\Handler::report() must be an instance of Exception, instance of TypeError given, called in /home/vagrant/Code/henau/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php on line 73 and defined in /home/vagrant/Code/henau/app/Exceptions/Handler.php:25
Stack trace:
#0 /home/vagrant/Code/henau/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(73): App\Exceptions\Handler->report(Object(TypeError))
#1 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleException(Object(TypeError))
#2 {main}
thrown

Even when I undo work that has been causing it, It stays. It's being caused by this block of code in this instance

即使我撤消了导致它的工作,它仍然存在。它是由这个实例中的这段代码引起的

\Mail::send('emails.registered', $user, function ($m) {
    $m->to('[email protected]')->subject('New Order');
});

It seems to me the error is not directly code-related. I've seen other people encounter it in complete different situations. And i've seen it popup in older threads regarding Homestead and PHP7. There was an askubuntu thread but it's offline, So I hope we can reopen the discussion here.

在我看来,该错误与代码没有直接关系。我见过其他人在完全不同的情况下遇到它。我已经在有关 Homestead 和 PHP7 的旧线程中看到它弹出。有一个 askubuntu 线程,但它处于离线状态,所以我希望我们可以在这里重新讨论。

回答by Miguel Stevens

Solution

解决方案

This is actually an error that an exception can't be shown. This is caused by using PHP7.x on an older Laravel project that requires PHP5.6.x

这实际上是一个无法显示异常的错误。这是由于在需要 PHP5.6.x 的旧 Laravel 项目上使用 PHP7.x 引起的

My solution was to create a new Homestead specific for this project and install php5.6 on that homestead using an older version of laravel/homestead

我的解决方案是为此项目创建一个新的 Homestead,并使用旧版本的 laravel/homestead 在该 homestead 上安装 php5.6

回答by Carlos Adames

I had the same problem when running seeders Notflip. I'm usign Laravel framework 5.0.34. I had this structure:

运行播种机Notflip时我遇到了同样的问题。我使用 Laravel 框架 5.0.34。我有这样的结构:

App/Models/Users/ (My users's Models here)

App/Models/Users/(我的用户模型在这里)

After moving my users's models to the Appdirectory, my seeder problem was solved.

将我的用户模型移动到App目录后,我的播种机问题就解决了。

Check your namespaces and put under consideration your Laravel Framework version before make changes in the framework.

在框架中进行更改之前,请检查您的命名空间并考虑您的 Laravel 框架版本。

Hope it helps!

希望能帮助到你!

回答by Harshi Srivastava

This situation occur when laravel project version not compatible or not configured with your local installed version So the laravel not tracking the exact error and instead of showing exact error on line shows that type of errors

当 laravel 项目版本不兼容或未与您本地安装的版本配置时会发生这种情况,因此 laravel 没有跟踪确切的错误,而不是在线显示确切的错误,而是显示该类型的错误

i had same problem in laravel 5.1. After reading this issue, i found out i was using laravel v5.1.0 and that seemed wrong so changed 5.1.0 to 5.1.* and ran composer update. this solved the issue for me.

我在 Laravel 5.1 中遇到了同样的问题。阅读此问题后,我发现我使用的是 laravel v5.1.0,这似乎是错误的,因此将 5.1.0 更改为 5.1.* 并运行 composer update。这为我解决了这个问题。