Bird
0
0

Identify the error in this route group code:

medium📝 Debug Q14 of 15
Laravel - Routing
Identify the error in this route group code:
Route::group(['middleware' => 'auth'], function {
    Route::get('profile', function () {
        return 'User Profile';
    });
});
AMissing parentheses after function keyword
BMiddleware should be an array, not a string
CRoute::group cannot use middleware
DRoute URI 'profile' is invalid
Step-by-Step Solution
Solution:
  1. Step 1: Check Closure Syntax

    The anonymous function must have parentheses: function() { ... }.
  2. Step 2: Validate Middleware Usage

    Middleware can be a string or array, so that is correct here.
  3. Final Answer:

    Missing parentheses after function keyword -> Option A
  4. Quick Check:

    Anonymous function needs () after function [OK]
Quick Trick: Always add () after function keyword for closures [OK]
Common Mistakes:
  • Omitting parentheses in anonymous functions
  • Thinking middleware must be array always
  • Assuming route URI 'profile' is invalid

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Laravel Quizzes