我想禁用 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模板网!
MySQLi准备好的语句&foreach 循环MySQLi prepared statement amp; foreach loop(MySQLi准备好的语句amp;foreach 循环)
mysqli_insert_id() 是从整个服务器还是从同一用户获Is mysqli_insert_id() gets record from whole server or from same user?(mysqli_insert_id() 是从整个服务器还是从同一用户获取记录?)
PHP MySQLi 无法识别登录信息PHP MySQLi doesn#39;t recognize login info(PHP MySQLi 无法识别登录信息)
mysqli_select_db() 需要 2 个参数mysqli_select_db() expects exactly 2 parameters(mysqli_select_db() 需要 2 个参数)
Php mysql pdo 查询:用查询结果填充变量Php mysql pdo query: fill up variable with query result(Php mysql pdo 查询:用查询结果填充变量)
MySQLI 28000/1045 用户“root"@“localhost"的访问MySQLI 28000/1045 Access denied for user #39;root#39;@#39;localhost#39;(MySQLI 28000/1045 用户“root@“localhost的访问被拒绝)