我可以在异常处理程序中访问环境变量吗

时间:2019-10-17 06:04:34

标签: php laravel null environment-variables

我需要在.env的{​​{1}}文件中获取常量,

我更改了 Handle.php

Exception/Handler.php

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

2 个答案:

答案 0 :(得分:1)

答案 1 :(得分:0)

    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.