disable laravel#39;s built in error screen(禁用 Laravel 的内置错误屏幕)
问题描述
我想禁用 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 的内置错误屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:禁用 Laravel 的内置错误屏幕


- Laravel 5:Model.php 中的 MassAssignmentException 2021-01-01
- 如何从数据库中获取数据以在 laravel 中查看页面? 2022-01-01
- 覆盖 Magento 社区模块控制器的问题 2022-01-01
- 使用 GD 和 libjpeg 支持编译 PHP 2022-01-01
- 如何使用 Google API 在团队云端硬盘中创建文件夹? 2022-01-01
- PHP foreach() 与数组中的数组? 2022-01-01
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- openssl_digest vs hash vs hash_hmac?盐与盐的区别HMAC? 2022-01-01
- 如何在 Symfony2 中正确使用 webSockets 2021-01-01
- PHP - if 语句中的倒序 2021-01-01