Debugging is a helpful feature for developers to identify the causes of issues. Most of the modern application frameworks provide you the option to enable debug mode including Laravel. It is a good idea to keep enabling debug mode in your development environment. In your production environment, this value should always be false.
What is debug mode in Laravel?
When your application is in debug mode, detailed error messages with stack traces will be shown on every error that occurs within your application. If disabled, a simple generic error page is shown.
In this blog, you will learn how to enable and disable debug mode in Laravel. Having a debug mode is very important in order to show errors during local development.
Enable Debug
Laravel provides APP_DEBUG
flag in .env file to handle application debug mode, default it true
and when you change to false
it means you are disabling debug mode.
Search APP_DEBUG
key in .env
file and change true to enable debug mode and false
for disable debug mode.
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost
LOG_CHANNEL=single
Disable Debug
Set the APP_DEBUG environment variable value to false
in the .env
environment configuration file.
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=false
APP_URL=http://localhost
LOG_CHANNEL=single
Read Also: Laravel 8 Send Mail using Queue Tutorial
Enable or disable debug mode using app.php
Open the app.php file located in your config/app.php laravel project. Search for debug
key and change true to enable debug mode and false
for disabling debug mode default it will show false
.
'debug' => env('APP_DEBUG', false),
Enable Debug
'debug' => env('APP_DEBUG', true),
Disable Debug
'debug' => env('APP_DEBUG', false),
Thank you for reading this blog.
Read Also: Laravel 8 Server Side Datatables Tutorial