Bird
0
0

You want to override a config value at runtime without changing the config files. Which Laravel method allows you to do this?

hard📝 Application Q9 of 15
Laravel - Configuration and Environment
You want to override a config value at runtime without changing the config files. Which Laravel method allows you to do this?
Aconfig(['app.locale' => 'fr'])
Benv('app.locale', 'fr')
CsetConfig('app.locale', 'fr')
DConfig::set('app.locale', 'fr')
Step-by-Step Solution
Solution:
  1. Step 1: Recall how to set config values at runtime

    Laravel's config() helper can accept an array to override config values temporarily.
  2. Step 2: Differentiate from other methods

    env() reads environment variables, setConfig() does not exist, and Config::set() is not the correct static method.
  3. Final Answer:

    config(['app.locale' => 'fr']) -> Option A
  4. Quick Check:

    Override config at runtime with config(array) [OK]
Quick Trick: Override config by passing array to config() helper [OK]
Common Mistakes:
  • Using env() to override config
  • Assuming setConfig() exists
  • Using incorrect static method

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Laravel Quizzes