Drupal 8, Grounded in Symfony

Logo 05 Drupal

Drupal is a powerful open-source and flexible content management system (that’s why we love working with it).  But lets face it, it’s earlier versions have a few “wrinkles.”

While PHP has drastically evolved in the past few years, Drupal has lagged behind a bit, especially with adopting and promoting solid software engineering pattern, such as object oriented programming, model-view-controller (MVC), or REST.

Because of this, Drupal developers often devised their own creative means to solve their coding issues – which often resulted in Drupal installations plagued with spaghetti and redundant code, HTML markup all over the place, and poor performance.

To support the industry best practices and empower serious developers, Drupal announced in 2012 it would entirely revamp its core by using some of the components found in Symfony 2, an enterprise-level and open source MVC framework for PHP.  That’s where Drupal 8 comes in.

And we can’t wait!

Here’s a list of some of the main Symfony libraries integrated in Drupal 8 and their benefits.

Twig Template Engine

At last there will finally a better way to code and manage views in Drupal. Twig will allow Web designers to more easily skin interfaces instead of expecting them to figure out PHP code, especially when the HTML output is the result of many cryptic hooks and other “alter” statements. It’ll certainly make things a lot smoother when it comes to building responsive apps.

YAML (YAML Ain’t Another Markup Language)

YAML has been part of Symfony since its inception. It allows for more expressive configuration than typical INI files without using a cumbersome markup language, such as XML. YAML is used by Drupal 8 to configure routes, modules, and other components. The Symfony YAML library also provides means to easily retrieve configuration values in your code.


You will be able to define and maintain routing rules and other SEO-friendly URLs in a routing file written in YAML. Here’s an example of a routing file for a custom module.

example.content: path: '/example' defaults: _controller: '\Drupal\example\Controller\ExampleController::content' _title: 'Hello World' requirements: _permission: 'access content' Request components (HttpKernel, HttpFoundation, EventDispatcher) and Serializer

Those Symfony components interpret the HTTP request to route it to the proper piece of code or module and build the appropriate response. It will enable Drupal 8 with top-notch web services and REST capabilities out-of-the-box.

Paired with Symfony 2 Serializer, exposing your data and content in a variety of formats from XML to JSON won’t feel as cumbersome as it currently is.


Right now, Drupal doesn’t really come with a solid foundation to do a lot of validation aside from using “form schemas.” Symfony Validator is a powerful library to validate incoming requests, forms, and even objects, through class metadata and annotations. You’ll be able to more efficiently write and reuse your own validation rules.


Drupal 8 uses the Symfony Translation component to manage language files and distribute content in multiple languages.

What To Do Next

If you want to get a head start, there are many tutorials out there describing how to use a Model-View-Controller approach to build a Drupal 8 module.

However D8’s code base isn’t stable yet and following the official documentation is the safest thing to do. For example, this page describes how to build a controller action and route a request to it.

This is a major revolution for Drupal. Migrating from Drupal 6/7 to 8 is likely to require the rewrite of many applications. However, software engineers and serious developers will welcome this new version with its Symfony foundation. It will foster greater code discipline through well-accepted standards, make code more legible and testing a lot easier.