0
0
Laravelframework~10 mins

Debug mode in Laravel - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to enable debug mode in Laravel's .env file.

Laravel
APP_DEBUG=[1]
Drag options to blanks, or click blank then click option'
Afalse
Btrue
Cyes
Dno
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'yes' or 'no' instead of true or false
Forgetting to restart the server after changing .env
2fill in blank
medium

Complete the code to clear the configuration cache so debug changes take effect.

Laravel
php artisan [1]
Drag options to blanks, or click blank then click option'
Acache:clear
Bview:clear
Croute:clear
Dconfig:clear
Attempts:
3 left
💡 Hint
Common Mistakes
Using cache:clear which clears application cache but not config cache
Using route:clear or view:clear which clear other caches
3fill in blank
hard

Fix the error in the code to log debug information conditionally.

Laravel
if (config('app.debug')) {
    Log::[1]('Debug mode is active');
}
Drag options to blanks, or click blank then click option'
Aerror
Binfo
Cdebug
Dalert
Attempts:
3 left
💡 Hint
Common Mistakes
Using info or error which are different log levels
Using alert which is for urgent messages
4fill in blank
hard

Fill both blanks to set debug mode off and clear the config cache.

Laravel
APP_DEBUG=[1]
php artisan [2]
Drag options to blanks, or click blank then click option'
Afalse
Bconfig:clear
Ccache:clear
Dtrue
Attempts:
3 left
💡 Hint
Common Mistakes
Using true instead of false to disable debug
Clearing cache instead of config cache
5fill in blank
hard

Fill all three blanks to log an error only if debug mode is off.

Laravel
if (!config('app.debug')) {
    Log::[1]('Error occurred');
    report(new Exception([2]));
    return response()->json(['error' => [3]], 500);
}
Drag options to blanks, or click blank then click option'
Aerror
B'Debug mode disabled error'
C'An error happened'
Ddebug
Attempts:
3 left
💡 Hint
Common Mistakes
Using debug log level when debug is off
Mismatching error messages in exception and response