As a developer, debugging is very handy when you are finding that irritating bug. Thanks to laravel, we have debug mode.
In this post we will see how you can enable and disable debug mode in laravel application.
This tutorial can be used with laravel 6, laravel 7, laravel 8 and laravel 9 as well.
Lets get started!
Laravel have “.env” file in which there is flag “APP_DEBUG” for enabling and disabling debug mode. If you disable it, it will not show details of any errors.
However, if you are developer and enable it, you can easily debug and find the source of the error and knock those bugs.
Here is how you can do it.
Table of Contents
Enable Debug Mode
Go the “.env” file and look for “APP_DEBUG” flag. Make it “true” for enabling the debug mode in laravel.
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:ckmYpNLcVCGTLZXDn6MgoG7Eyc3qbd3lZkLcm20xV4U=
APP_DEBUG=true
APP_URL=http://localhost
Disable Debug Mode
Go to “.env” file and see the “APP_DEBUG” flag. If it is “true”, make it “false” to disable the debug mode in laravel.
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:ckmYpNLcVCGTLZXDn6MgoG7Eyc3qbd3lZkLcm20xV4U=
APP_DEBUG=false
APP_URL=http://localhost
Enable or Disable Debug mode using app file
Now we see how we can enable and disable the debug mode using the “app.php” file.
Enable Debug mode using app.php file
First of all, go to the “app.php” and look for “debug” key. If it is set to the “false”. Make sure to set it to “true”.
'debug' => env('APP_DEBUG', true),
Disable Debug mode using app.php file
Go to the “app.php” and see for “debug” key. If its “true”, set it “false” to disable the debug mode using “app.php” file
'debug' => env('APP_DEBUG', false),
Conclusion
Hope in the above article you have learned today how to enable and disable debug mode in laravel.
Let me know if you have any questions
Happy Coding 🙂
Write a Reply or Comment