Enable and Disable Debug Mode in Laravel

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. Laravel also provides a good debugger to help the developer identify problems before going to production.

But be careful with debug mode because if it’s on in the production server then it can reveal sensitive information about the application and server.

Enable/Disable Debug Mode In Laravel

To change Laravel debug mode, you need to modify the .env file in the root directory of the application. There is a variable APP_DEBUG which will store the current status of debug mode. By default it’s True.

Refer below code

APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:Pv58f27htTXJ0W4kUL7y8C4oMuDFtNHNgNI8YvCEoie=
APP_DEBUG=true
APP_URL=http://test.test

To disable it just change the APP_DEBUG value to false like the below :

APP_DEBUG=false

Enable or Disable Debug Mode Using Application Configuration

In Laravel, you can also disable or enable debug mode using a configuration file. Open the app.php file located in your config/app.php Laravel project.

To Enable Debug

'debug' => (bool) env('APP_DEBUG', true),

To Disable Debug

'debug' => (bool) env('APP_DEBUG', false),