Understanding Drupal 8, part 1: the general structure of the framework

Part 1: The structure of Drupal 8

Drupal 8 is here. And it’s a revolution! Not an evolution like Drupal 7 compared to Drupal 6, but a completely different architecture and coding methodology! I am convinced that these big changes were necessary to professionalize and modernize the CMS. I believe that the shift towards object orientation will appeal to developers and will improve the overall software quality. I am thankful for the Drupal core developers for their braveness and work on this!

However, learning it is going to be a huge challenge to existing (and new) web developers. Give yourself an edge by reading this article! This article provides you with a starting point before diving into Drupal 8 module development. I’ve written it after studying both Symfony2 and Drupal 8 extensively for days, by using step-by-step debugging, code reading and online articles. I am an experienced Drupal 7 developer but knew nothing about Symfony and have not contributed to the Drupal 8 core (yet). I believe that by sharing what I’ve learned I can also improve your understanding of the subject.

This article will be published in four parts during the next four weeks. In this first part, we'll have a look at the general structure of the Drupal 8 framework, especially in relation to the Symfony2 components. We’ll see which Symfony2 components are used in Drupal and how. During the next part, we’ll have a detailed look at the all-important service container. In the 3rd part we’ll take a detailed look at bootstrapping and routing in Drupal 8. You’ll learn how requests are handled. In the 4th and final part, some other exciting and new, need-to-know, Drupal 8 features will be described.


The Symfony2 framework is designed to enable a developer to build custom web-based applications. Symfony is not a CMS, as it can't be used to administer a site. Instead, code must be written to create an application. Symfony provides a way to do that efficiently. In theory, a CMS could be written on top of Symfony. But in practice, the default approach of Symfony was found not flexible enough for Drupal.

Instead, for Drupal 8 it was opted to just use the (excellent) core layers of Symfony and extend it to provide support for Drupal modules. This has resulted in a well-balanced system, that uses a good (and unmodified) part of the Symfony core, but extends it with a very flexible CMS layer. The best of both worlds!


The Symfony framework consists out of several components. Some are vital to the system, such as the Http Foundation component that understands HTTP and offers a nice request and response object used by the other components. Others are merely helper components, such as the Validator, that helps to validate data (is it a valid email address/url/number/etc?). At the heart of the system is the Kernel component. This Kernel is basically the 'main class' that manages the environment (services and bundles) and has the responsibility of handling a http request. A developer may extend a system by extending the kernel, such as AppKernel extends Kernel, and adding his own bundles in there. These bundles can be used to create 'coherent' pieces of functionality, much like modules in Drupal.

Drupal uses only a some of Symfony's components, which can be seen in the image below.

How Drupal 8 extends Symfony2

Drupal does not extend Kernel, like a Symfony2 web app would. It offers the same type of functionality however by implementing the Kernel Interface. This is because Drupal does not share the 'bundle' approach of Symfony. Bundles provide a great way to build custom web applications, but are less suited for building a CMS that must be very flexible and extendible. The DrupalKernel loads the environment (available services and modules) in a slightly different (but similar) way than Kernel, but delegates request handling to the HttpKernel, just like Symfony's Kernel does.

Furthermore, Drupal 8 brings its own (3rd party) components and core code. A schematic overview is shown in the following image.


This concludes the first part of the ‘Start learning Drupal 8’ article. Next week, we’re going to explain about the Service Container, which can be considered as the back bone of the Drupal system. You need to know about it before knowing about any of the other components.

Other parts

Part 1: The Structure of Drupal 8
Part 2: Service Container
Part 3: Routing
Part 4: Plugins and Entities

Click here for more info on Cipix Internet Agency.