0
0
Laravelframework~5 mins

Debug mode in Laravel

Choose your learning style9 modes available
Introduction

Debug mode helps you find and fix errors in your Laravel app by showing detailed error messages.

When you are building a new feature and want to see errors clearly.
When something is not working and you need to understand why.
When you want to check the details of exceptions or bugs.
When testing your app locally before making it live.
Syntax
Laravel
APP_DEBUG=true

This is set in the .env file at the root of your Laravel project.

Set APP_DEBUG=false in production to hide error details from users.

Examples
This shows detailed error messages in your browser.
Laravel
# Enable debug mode
APP_DEBUG=true
This hides error details and shows a generic error page instead.
Laravel
# Disable debug mode
APP_DEBUG=false
Sample Program

This route causes a division by zero error. If APP_DEBUG=true, Laravel shows a detailed error page. If false, it shows a simple error message.

Laravel
<?php

// routes/web.php
use Illuminate\Support\Facades\Route;

Route::get('/debug-example', function () {
    // This will cause an error if debug mode is on
    return 1 / 0;
});
OutputSuccess
Important Notes

Always turn off debug mode (APP_DEBUG=false) on live sites to protect sensitive info.

After changing APP_DEBUG, clear config cache with php artisan config:clear to apply changes.

Summary

Debug mode shows detailed error info to help fix bugs.

Set APP_DEBUG=true in .env to enable it.

Turn it off in production for security by setting APP_DEBUG=false.