Bird
0
0

How do you register a single action controller route in Laravel's routes file?

easy📝 Conceptual Q2 of 15
Laravel - Controllers
How do you register a single action controller route in Laravel's routes file?
ARoute::get('/path', [ControllerName::class, 'handle']);
BRoute::get('/path', ControllerName::class);
CRoute::get('/path', 'ControllerName@index');
DRoute::get('/path', 'ControllerName@handle');
Step-by-Step Solution
Solution:
  1. Step 1: Recall route registration for single action controllers

    Single action controllers are registered by passing the controller class name only.
  2. Step 2: Match the correct syntax

    Route::get('/path', ControllerName::class); is the correct way to register.
  3. Final Answer:

    Route::get('/path', ControllerName::class); -> Option B
  4. Quick Check:

    Single action controller route = ControllerName::class [OK]
Quick Trick: Use ControllerName::class for single action routes [OK]
Common Mistakes:
  • Using method strings like 'handle'
  • Using array syntax with method name
  • Forgetting ::class

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Laravel Quizzes