简体   繁体   English

调试模式无法在Laravel 4中按预期方式工作

[英]Debug mode not working as expected in Laravel 4

I am running into a strange issue when trying to add 404 pages to my application. 尝试将404页添加到应用程序时遇到一个奇怪的问题。

I have two separate folders that I use for different configurations, one for my local environment and one for production. 我有两个用于不同配置的单独文件夹,一个用于本地环境,一个用于生产。

So, when I change my "debug" => true in my local configuration, I get a Whoops! 因此,当我在本地配置中更改"debug" => true时,我会大声疾呼! as I expect. 如我所料 Changing that option to false shows me a general error message, which I would also expect. 将该选项更改为false显示一条一般错误消息,这也是我所期望的。

The problem comes about when I try to edit that general error message. 当我尝试编辑该一般错误消息时,就会出现问题。 The documentation states to add something like this into your app (which I have done): 文档指出要在您的应用中添加类似的内容(我已经完成了):

App::missing(function() {
    return "Not found!";
});

What happens is no matter if my local environment's debug is set to true or false it will always return that message if that code is placed within my application. 无论我的本地环境的debug设置为true还是false ,无论发生什么事情,如果将该代码放在我的应用程序中,它将始终返回该消息。 I want to be able to see a Whoops! 我希望能够看到一个呐喊! on my local environment but on production they should receive a general error message. 在我的本地环境中,但在生产环境中,它们应该会收到一般错误消息。

Am I doing something wrong here? 我在这里做错什么了吗? How can I receive a Whoops! 我怎样才能收到呐喊! screen to track down bugs locally but send a 404 message in production?? 屏幕以在本地跟踪错误,但在生产中发送404消息?

Detect your environment first and then setup the error you want to show on that env 首先检测您的环境,然后设置要在该环境中显示的错误

if (App::environment('local'))
{
    App::missing(function() {
        return "Not found!";
    });
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM