What is routing in Laravel?

Why Interviewers Ask This

This question tests conceptual clarity. Interviewers want to hear a precise, confident definition before moving to more complex Laravel topics. It also reveals how well you can explain technical ideas to non-experts.

Answer

Laravel's routing system maps incoming HTTP requests to specific controller actions or closures. Define routes in routes/web.php (for web routes with session/CSRF) or routes/api.php (for stateless API routes). Example: Route::get("/users", [UserController::class, "index"]);. Laravel supports all HTTP verbs: get, post, put, patch, delete. Route parameters: Route::get("/users/{id}", ...). Optional parameters: {id?}. Constraints: ->where("id", "[0-9]+"). Route naming: ->name("users.index") lets you generate URLs with route("users.index") instead of hardcoding paths.

Pro Tip

If you're unsure about a detail, say so honestly and explain your reasoning. Interviewers respect candidates who can think through uncertainty rather than bluffing.