Могу ли я получить доступ к переменным env в Exception Handler - PullRequest
0 голосов
/ 17 октября 2019

Мне нужно получить константы в файле .env в Exception/Handler.php,

У меня есть изменения 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 , есть идеи?

Ответы [ 2 ]

1 голос
/ 17 октября 2019
0 голосов
/ 17 октября 2019
    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.
...