Bird
0
0

What will be the URL for the route defined below?

medium📝 component behavior Q5 of 15
Laravel - Routing
What will be the URL for the route defined below?
Route::prefix('api')->group(function () {
    Route::prefix('v2')->group(function () {
        Route::get('users', [UserController::class, 'list']);
    });
});
A/v2/api/users
B/api/v2/users
C/api/users
D/users
Step-by-Step Solution
Solution:
  1. Step 1: Understand nested prefix groups

    Nested prefix groups concatenate their prefixes in order.
  2. Step 2: Combine prefixes with route path

    Prefixes 'api' and 'v2' combine to 'api/v2', then add 'users' route path.
  3. Final Answer:

    /api/v2/users -> Option B
  4. Quick Check:

    Nested prefixes concatenate in URL [OK]
Quick Trick: Nested prefixes combine in URL path [OK]
Common Mistakes:
  • Reversing prefix order
  • Ignoring inner prefix
  • Using only one prefix

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Laravel Quizzes