我想禁用 Laravel 的错误屏幕,该屏幕显示带有调试信息和函数跟踪的错误/异常.主要是因为我使用 Laravel 作为移动 API 后端,而这些响应在移动设备上更难阅读.
I want to disable Laravel's error screen that shows the errors/exceptions with debugging information and functions trace. Mostly because I'm using Laravel as mobile API backend and those responses are harder to read on a mobile device.
请注意,我想要错误,而不是花哨的错误页面.
Please notice that I want the errors, but not the fancy error page.
有什么建议吗?
进入Laravel项目->app文件夹->config文件夹->app.php设置
Go to Laravel project -> app folder-> config folder -> app.php set
'debug' => false,
这将显示一个简单的错误页面,如 Ops!出了点问题.
This will show a simple error page like Ops! Something went wrong.
Laravel App Facade 提供了一种使用 Laravel 文档中提到的错误方法来捕获异常的方法
Laravel App facade provides a way to way catch the exceptions using error method as mentioned in the Laravel docs
App::error(function(Exception $exception)
{
// handle your exception
});
你可以在filters.php中放置App::error方法
You can place App::error method in the filters.php
如果你想进一步往下看,Laravel 正在使用 Symfony 来显示这些页面.我还没有真正尝试过改变这件事,也许有人会想出更好的答案.
and Laravel is using Symfony to display those pages if you want to further go down. I have not really tried to change this thing, maybe someone will come up with a better answer.
这篇关于禁用 Laravel 的内置错误屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!