如何在 Laravel 上检查调试模式

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/41128469/
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 14:55:03  来源:igfitidea点击:

How can I check debug mode on Laravel

phplaravel

提问by rgn

I want to see errors when I work in the localhost.

我想在本地主机中工作时看到错误。

App\Exceptions\handler.php

应用\异常\handler.php

I Tried:

我试过:

public function render($request, Exception $exception)
{
    if ($this->isHttpException($exception) && env('APP_DEBUG') === false) {
        return response()->view('errors.404', [], 404);
    } else {
        return parent::render($request, $exception);
    }
}

or;

或者;

if ($this->isHttpException($exception) && App::environment('APP_DEBUG') === false)

I tried it as above but it does not work.

我按照上面的方法尝试过,但它不起作用。

Thanks.

谢谢。



APP_DEBUG is set to true in .env

APP_DEBUG 在 .env 中设置为 true

回答by insign

To avoid big problems with cache, the right way to check is:

为了避免缓存出现大问题,正确的检查方法是:

config('app.debug') == false

config('app.debug') == false

回答by user8271849

Try to change

尝试改变

env('APP_DEBUG') === false

to

env('APP_DEBUG') == false

回答by Ferran

In your .env file you should have:

在你的 .env 文件中,你应该有:

APP_DEBUG=true