我可以访问异常处理程序中的env变量吗



我需要在Exception/Handler.php.env文件中获取常量,

我更改了Handle.php

public function render($request, Exception $exception)
{
if (env('APP_DEBUG')) {
return parent::render($request, $exception);
} else {
return response(view('error_custom')->render(),200);
}
}

env('APP_DEBUG')返回null,有什么想法吗?

As you know you have debug variable in env something like the below:
'debug' => env('APP_DEBUG', false);
Laravel 5+:
then you can access it like $debug = config('app.debug');
Laravel 4.2:
$debug = Config::get('app.debug');
but before going further just check you get the value for it, if you have set value of APP_DEBUG as false in env then you will get 0 but you can't see it while printing so create a condition such as
if (config('app.debug')) {
echo "Yes";
} else {
echo "No";
}
once you get the output you are ready to go further.

相关内容

  • 没有找到相关文章

最新更新