How to Enable and Disable Debug Mode in Laravel

  Suresh Ramani   Laravel   3 weeks ago
How to Enable and Disable Debug Mode in Laravel - TechvBlogs

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

If you want to manage your VPS / VM Server without touching the command line go and  Checkout this linkServerAvatar allows you to quickly set up WordPress or Custom PHP websites on VPS / VM in a  matter of minutes.  You can host multiple websites on a single VPS / VM, configure SSL certificates, and monitor the health of your server without ever touching the command line interface.

If you have any queries or doubts about this topic please feel free to contact us. We will try to reach you.

Tags:
Laravel PHP

Suresh Ramani - Author - TechvBlogs
Suresh Ramani
Full Stack Developer