🔴 Laravel
Beginner
What is routing in Laravel?
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.