Add a Wildcard to a Route

Video loading...

Transcripts: 
Transcript language code: 
eng
Transcript language code: 
por_br

Join Drupalize.Me to watch this video

Join today and gain instant access to our entire video library.

Log in Sign up
  • 0:08
    Routing is packed with cool little features.
  • 0:11
    But the most common thing you'll see
  • 0:13
    is the addition of wildcards.
  • 0:16
    Add a /{count}
  • 0:19
    to the end of the route's path.
  • 0:20
    Because this is surrounded
  • 0:22
    with curly braces,
  • 0:23
    the route will now match:
  • 0:24
    /the/dino/says/*ANYTHING*.
  • 0:29
    And as soon as you have
  • 0:08
    O roteamento no Drupal 8 é cheio de funcionalidades legais.
  • 0:11
    Mas a coisa mais comum que você vai ver
  • 0:13
    é a adição de curingas (wildcards).
  • 0:16
    Adicione um /{soma}
  • 0:19
    no final do caminho da rota.
  • 0:20
    Porque isso é colocado
  • 0:22
    entre chaves,
  • 0:23
    a rota irá corresponder à:
  • 0:24
    /the/dino/says/*QUALQUER_COISA*/.
  • 0:29
    E logo que você tiver

Add a Wildcard to a Route

Loading...

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.