juniorLaravel
What are Laravel routes and how do they work?
Updated May 16, 2026
Short answer
Routes define how application URLs map to controller actions or closures.
Deep explanation
Laravel routing handles HTTP requests by mapping URLs to callbacks or controller methods. Routes can be defined in web.php or api.php. Middleware can be attached for authentication, logging, or throttling.
Real-world example
Used to define API endpoints like /api/users or /login.
Common mistakes
- Defining too many closures instead of controllers.
Follow-up questions
- What is route caching?
- Difference between web.php and api.php?