Module Development

Overview: Parameters and Value Upcasting in Routes for Drupal 8, 9, and 10

The routing system can get dynamic values from the URL and pass them as arguments to the controller. This means a single route with a path of /node/{node} can be used to display any node entity. Route parameters can be validated, and upcast to complex data types via parameter conversion. If you ever want to pass arguments to the controller for a route, you'll use parameters to do so.

In this tutorial we'll:

  • Define what parameters (slugs, placeholders) are and what they are used for in a route definition.
  • Explain how URL parameters are passed to a controller.
  • Define parameter upcasting.

By the end of this tutorial, you should be able to explain how to define a route that uses parameters to pass dynamic values to the route controller, and explain how parameter upcasting works.