Bird
0
0

What is wrong with this route group declaration?

medium📝 Debug Q7 of 15
Laravel - Routing
What is wrong with this route group declaration?
Route::group(['middleware' => 'auth'], function() {
    Route::get('dashboard', 'DashboardController@index');
});
AController action should be an array, not a string
BMissing semicolon after Route::get
CMiddleware key should be 'middlewares'
DRoute::group requires a prefix option
Step-by-Step Solution
Solution:
  1. Step 1: Check controller action syntax in routes

    In modern Laravel 8+, controller actions should be passed as arrays like [ControllerClass::class, 'method']. The string 'Controller@method' syntax is legacy.
  2. Step 2: Identify correct syntax for Laravel 8+

    Modern Laravel prefers array syntax for controller actions instead of string.
  3. Final Answer:

    Controller action should be an array, not a string -> Option A
  4. Quick Check:

    Use array syntax for controller actions in routes [OK]
Quick Trick: Use array syntax for controller actions in modern Laravel [OK]
Common Mistakes:
  • Using string syntax for controller actions in new Laravel
  • Confusing middleware key spelling
  • Assuming prefix is mandatory

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Laravel Quizzes