What will you learn
- Which Symfony components Drupal uses
- The purpose of each component
- How Drupal customizes the components
- Where to find documentation
Beginning with Drupal 8, Modern Drupal replaced several internal subsystems with components from the Symfony project. Drupal 10 now uses Symfony 6 as a dependency and requires PHP 8.1. While it's not necessary to know these components inside and out to be a competent Drupal developer, Drupal provides an interesting set of use cases for their implementation. By understanding what they are, where they come from, and Drupal customizes them, you’ll have a better foundation to understand Drupal. And you’ll learn transferable skills that will come in handy as you encounter other PHP-based projects that use Symfony components.
Drupal includes these Symfony packages, called components, in its codebase. When you install Drupal locally, you will find these in your project’s vendor directory. Drupal’s internal classes, located in core/lib include customizations to key components.
Each component links to its official Symfony documentation.
- Polyfill Iconv
Begin with these blog posts in our Spotlight on Symfony series. This will give you a high-level overview of the components in Drupal.
- Part 1: HttpKernel in Drupal
- Part 2: EventDispatcher in Drupal
- Part 3: Routing in Drupal
- Part 4: Utility Components in Drupal
The Symfony components documentation is an excellent resource for understanding each individual component. Some components are used in Drupal without any customization at all, while some have a high degree of customization, like the Routing system.
Web frameworks all have similar basic functionality requirements. Fundamentally they are responsible for managing incoming HTTP requests, making sense of them somehow, and responding to them. See How Drupal Turns a Request into a Response to see this process in detail.
The HttpKernel component handles the heavy lifting for the request and response handling. It makes use of the HttpFoundation component to provide a more developer-friendly object-oriented layer for manipulating the types of data that is handled at the HTTP layer.
Once the incoming HTTP request has been parsed the framework needs to figure out how to respond. This is the job of the Routing and EventDispatcher components. Our Overview: Routes, Controllers, and Responses tutorial is a great place to continue learning about this process.
The EventDispatcher and the use of the Dependency Injection components represent design patterns decisions that are incredibly common among other frameworks. What Are Events? provides an overview for how Drupal makes use of the EventDispatcher pattern.
The rest of the components in core can be considered utility components. They provide very specific functionality and usually don't require much additional customization. A good example of this is the Yaml component which handles loading, parsing and writing YAML files. Learn more about these types of components on our Utility Functions and Classes topic page and in our blog post on Utility Components.
Our Symfony topic page also includes a round-up of both Drupalize.Me and external resources about Symfony in Drupal: