Module Development

How Drupal Turns a Request into a Response for Drupal 8, 9, and 10

Every web framework, including Drupal, has basically the same job: provide a way for developers to map URLs to the code that builds the corresponding pages. Drupal uses Symfony's HTTPKernel component. Kernel events are dispatched to coordinate the following tasks:

  • Process the incoming request
  • Figure out what to put on the page
  • Create a response
  • Deliver that response to the user's browser

Knowing a bit more about how Drupal handles the request-to-response workflow will help you better understand how to use routes and controllers to create your own custom pages or deal with authentication, access checking, and error handling in a Drupal module.

In this tutorial we'll:

  • Walk through the process that Drupal uses to convert an incoming request into HTML that a browser can read
  • See how the Symfony HTTPKernel helps orchestrate this process
  • Learn about how the output from a custom controller gets incorporated into the final page

By the end of this tutorial, you should be able to describe the process that Drupal goes through to convert an incoming request for a URL into an HTML response displayed by the browser.