Bird
0
0

You want to automate Laravel app setup including key generation in a deployment script. Which sequence is correct?

hard📝 Application Q15 of 15
Laravel - Configuration and Environment
You want to automate Laravel app setup including key generation in a deployment script. Which sequence is correct?
ACopy .env.example to .env, run php artisan config:cache, then run php artisan key:generate
BRun php artisan config:cache, then copy .env.example to .env, then run php artisan key:generate
CRun php artisan key:generate, then copy .env.example to .env, then run php artisan config:cache
DCopy .env.example to .env, run php artisan key:generate, then run php artisan config:cache
Step-by-Step Solution
Solution:
  1. Step 1: Prepare environment file

    First, copy .env.example to .env to create the environment config file.
  2. Step 2: Generate the application key

    Run php artisan key:generate to set the APP_KEY in the new .env file.
  3. Step 3: Cache the configuration

    Run php artisan config:cache to cache the config including the new key for performance.
  4. Final Answer:

    Copy .env.example to .env, run php artisan key:generate, then run php artisan config:cache -> Option D
  5. Quick Check:

    Copy .env -> key:generate -> config:cache [OK]
Quick Trick: Copy .env first, then key:generate, then config:cache [OK]
Common Mistakes:
  • Caching config before .env exists
  • Generating key before .env file is copied
  • Running key:generate after config:cache

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Laravel Quizzes