Module Development

Add a Wildcard to a Route for Drupal 8

Sprout Video

In this tutorial, you will learn how to return a response through a controller using route wildcards. We'll walk through how the wildcard in the route was created and then how this wildcard gets passed as a parameter to the controller function, enabling you to display a value to the page based on the value in a particular URL path segment using Symfony's Response object.

We're assuming you have the Drupal Console up and running (which we set up in the previous tutorial). The drupal command calls Drupal Console.

Curious about the inner workings of the HTTP response? Dive into Symfony and HTTP Fundamentals, which takes you from HTTP fundamentals to how PHP handles HTTP requests and responses, and integrates what Symfony's tools bring to this flow from request to response.

Additional resources

Symfony and HTTP Fundamentals — Symfony Documentation
Http Foundation Response Object — Symfony Documentation