← Back to Course

Route Parameters and Named Routes

Real applications rarely have only static URLs — a blog needs a route per post, a shop needs a route per product. Laravel handles this through route parameters, and it lets developers reference routes by name instead of hardcoding URLs everywhere.

Route Parameters

A route parameter is a placeholder in the URL pattern that captures part of the request and passes it into the controller or closure. Parameters can be required or optional, and Laravel supports constraining them with regular expressions when needed.

Named Routes

Rather than typing out full URLs throughout an application, Laravel lets you assign a name to a route and generate links or redirects using that name instead. If the underlying URL ever changes, every reference automatically updates, since nothing depends on the literal path.

SyntaxExample
Required parameterRoute::get('/post/{id}', ...)
Optional parameterRoute::get('/post/{id?}', ...)
Naming a routeRoute::get('/post/{id}', ...)->name('post.show')
Generating a URL from a nameroute('post.show', ['id' => 1])

Why This Matters

Routes work well for small amounts of logic, but as an application grows, that logic needs a proper home — which is exactly the role controllers play.

Ready to master Laravel Training Course?

Join Uncodemy's hands-on Laravel program and build real, production-ready applications.

Explore Course