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.
Confidence
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