Skip to content

How to enable debug mode in Laravel

Enable debug more in Laravel. Setting up APP_DEBUG environment variable in .env file of the Laravel. Disable debug mode in Laravel.

Steps
4
Category
PHP
Covers
Laravel
Versions & support
About Laravel →, About PHP →
On this page 4 steps

Laravel is a powerful PHP framework used for building web applications. Debugging is an essential part of the development process, and Laravel provides a robust set of debugging tools that can help developers identify and fix issues in their code. In this article, we’ll walk through the steps to enable debug mode in Laravel.

Step 1 of 4Set the APP_DEBUG variable to true

The first step to enabling debug mode in Laravel is to set the APP_DEBUG variable to true in your Laravel application’s .env file. The .env file is where you store your environment variables for your Laravel application.

To open the .env file, navigate to the root directory of your Laravel application and open the .env file with a text editor. Locate the APP_DEBUG variable and set it to true, as shown below:

See the screenshot below:

Enable debug mode in Laravel
Enable debug mode in Laravel

Save the changes to the .env file.

Step 2 of 4Set the APP_ENV variable to local

The next step is to set the APP_ENV variable to local in your .env file. This tells Laravel that you are running your application in a local environment and enables debug mode.

Save the changes to the .env file.

Step 3 of 4Clear the cache

After setting the APP_DEBUG and APP_ENV variables, you need to clear the cache. Laravel caches configuration files and other information to improve performance, and clearing the cache ensures that Laravel loads the updated environment variables.

To clear the cache, run the following command in the terminal or command prompt:

php artisan cache:clear 

Step 4 of 4Verify debug mode is enabled

To verify that debug mode is enabled, navigate to your Laravel application in a web browser. You should see detailed error messages and stack traces when an error occurs.

Conclusion

Enabling debug mode in Laravel is a straightforward process. By setting the APP_DEBUG and APP_ENV variables and clearing the cache, you can easily enable debug mode in your Laravel application. Laravel’s powerful debugging tools can help you quickly identify and fix issues in your code, making the development process faster and more efficient.

Rahul

Rahul Kumar is the founder and chief editor of TecAdmin.net. A Red Hat Certified Engineer (RHCE), he has worked in IT since 2009, with hands-on experience in Linux system administration, DevOps, web hosting, cloud platforms and automation. He started TecAdmin in 2013 to share practical, step-by-step guides, and leads its editorial work with one aim: making technical learning clear and useful for sysadmins, developers and beginners alike.

Leave a Reply

Your email address will not be published. Required fields are marked *


Back to top