0
0
Laravelframework~10 mins

Why configuration management matters in Laravel - Test Your Understanding

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

Complete the code to access the app name from the configuration in Laravel.

Laravel
$appName = config('[1]');
Drag options to blanks, or click blank then click option'
Aapp.name
Bdatabase.connections.mysql
Cmail.driver
Dcache.driver
Attempts:
3 left
💡 Hint
Common Mistakes
Using a wrong config key like 'database.connections.mysql' instead of 'app.name'.
Forgetting to use quotes around the config key.
2fill in blank
medium

Complete the code to set a configuration value at runtime in Laravel.

Laravel
config(['[1]' => 'smtp']);
Drag options to blanks, or click blank then click option'
Aapp.env
Bcache.store
Cmail.driver
Ddatabase.default
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to set 'app.env' when changing mail settings.
Using dot notation incorrectly without quotes.
3fill in blank
hard

Fix the error in the code to correctly cache the configuration in Laravel.

Laravel
php artisan config:[1]
Drag options to blanks, or click blank then click option'
Arefresh
Boptimize
Cclear
Dcache
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'clear' which clears the cache instead of caching it.
Using 'optimize' which is deprecated in recent Laravel versions.
4fill in blank
hard

Fill both blanks to create a config file array with database host and port.

Laravel
<?php

return [
    'host' => '[1]',
    'port' => [2],
];
Drag options to blanks, or click blank then click option'
A127.0.0.1
B3306
C5432
Dlocalhost
Attempts:
3 left
💡 Hint
Common Mistakes
Putting port number in quotes making it a string.
Using wrong port number like 5432 which is for PostgreSQL.
5fill in blank
hard

Fill all three blanks to retrieve a nested config value safely with a default fallback.

Laravel
$timezone = config('[1]', [2]); // default

// Using the value
if ($timezone === [3]) {
    echo 'Default timezone used';
}
Drag options to blanks, or click blank then click option'
Aapp.timezone
B'UTC'
Dapp.locale
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong config key like 'app.locale' for timezone.
Not providing a default value causing errors if config missing.