Reputation: 893
I want to see errors when I work in the localhost.
App\Exceptions\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
Upvotes: 15
Views: 25220
Reputation: 2742
Since Laravel version 8 and above:
You can just do like this:
$is_debug_mode = app()->hasDebugModeEnabled();
. .
Upvotes: 1
Reputation: 5358
You may use Application::hasDebugModeEnabled()
as an abstraction around the hardcoded config key.
Since Laravel 10, the method was also added to the Application contract.
Call it by either injecting the Illuminate\Contracts\Foundation\Application
contract into the constructor or by using the app() helper.
Upvotes: 5
Reputation: 5773
To avoid big problems with cache, the right way to check is:
config('app.debug') == false
Upvotes: 58
Reputation: 47
Try to change
env('APP_DEBUG') === false
to
env('APP_DEBUG') == false
Upvotes: -1