Last updated December 16, 2021

When Drupal receives an incoming request the HTTP Kernel identifies the appropriate route for the requested path. The routing system then matches this route with a controller that has been registered to handle responses for these types of requests. Sections of code responsible for generating the response to these requests are called Controllers.

Example tasks

  • Write the code in a custom module that responds to particular incoming requests
  • Understand how to identify the controllers responsible for responding to a given url, path and route.


Drupal's system of mapping request routes to controllers is quite well established. Since it's based on Symfony components it is unlikely to change dramatically in the foreseeable future.

Drupalize.Me resources

This tutorial covers how controllers work in the Symfony framework. Because Drupal is built on top of Symfony components, controllers in Drupal are very similar.

Controllers and Form API


More Guides

We have guides on many Drupal skills and topics.

Explore guides

External resources

  • Adding a basic controller (
    • This tutorial covers creating a very basic controller.
  • Routing and controllers in Drupal 8 (
    • This tutorial walks through creating a custom module, using Drupal Console, that creates a simple route and controller.
  • Examples' projects page_example module (
    • The Examples project contains many sub-modules that demonstrate various Drupal sub-systems through well-documented code. To learn more about how routing and controllers work, take a look at the page_example module here.