Routing system in Drupal 8

This routing system replaces the routing parts of hook_menu() in Drupal 7. The parts of hook_menu() that were for creating menu entries, tabs, actions and contextual links are taken over by other subsystems.

Overview

route is a path which is defined for Drupal to return some sort of content on. For example, the default front page, ‘/node’ is a route. When Drupal receives a request, it tries to match the requested path to a route it knows about. If the route is found, then the route’s definition is used to return content. Otherwise, Drupal returns a 404.

Routes and controllers

Drupal’s routing system works with the Symfony HTTP Kernel (that you need to know very little about to do basic route operations). This is how the components relate to each other:

 

 

 

 

 

Drupal8Routing

 

The routing system is responsible for matching paths to controllers, and you define those relations in routes. You can pass on additional information to your controllers in the route and access checking is integrated as well.