Bird
0
0

You need to add a new service provider to your Laravel project. Where should you place the service provider class and how do you register it?

hard📝 Application Q9 of 15
Laravel - Basics and Architecture
You need to add a new service provider to your Laravel project. Where should you place the service provider class and how do you register it?
APlace in app/Services and register in routes/web.php
BPlace in resources/providers and register in .env file
CPlace in app/Http/Controllers and register in composer.json
DPlace in app/Providers and register in config/app.php providers array
Step-by-Step Solution
Solution:
  1. Step 1: Locate service provider class

    Service providers are placed in app/Providers to organize application services.
  2. Step 2: Register provider correctly

    They must be registered in the providers array inside config/app.php to be loaded by Laravel.
  3. Step 3: Exclude incorrect options

    app/Services is not standard for providers, routes/web.php is for routes, composer.json and .env do not register providers.
  4. Final Answer:

    Place in app/Providers and register in config/app.php providers array -> Option D
  5. Quick Check:

    Service providers in app/Providers + config/app.php [OK]
Quick Trick: Service providers go in app/Providers and config/app.php [OK]
Common Mistakes:
  • Registering providers in routes files
  • Placing providers in resources folder
  • Trying to register in .env or composer.json

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Laravel Quizzes