Symfony and Drupal – Why Is It a Perfect Match?

Drupal is a highly efficient and flexible Open Source CMS. However, its previous versions (up to the 8th one) had particular issues. PHP evolved rapidly in past years, and unfortunately, Drupal adjustment to this development was not satisfying, especially in case of software engineering patterns adoption. That is why Drupal Developers had to come up with creative ways how to deal with the issues. To meet the programmers' expectations, in 2012, Drupal made the step forward – rebuilt its core using Symfony components.

Drupal and Symfony combination

Drupal 7 vs Drupal 8 – what Symfony changes?

At first, Drupal had an exact and procedural code. However, Drupal 8 works more on OOP, especially in case of API database. The procedural methods were sustained, for the developer's comfort who got used to such a solution. Symfony usage in Drupal 8 was a definite step to make the CMS more object-programming oriented. The visible proofs are, e.g. the controllers and service containers implementation (more about this beneath). Such a solution causes that Symfony programmers are more willing to work on Drupal 8.

Pros of Symfony and Drupal combination

The main advantage is pretty simple – Symfony makes Drupal more similar to other business solutions. Thanks to that, Drupal Developers can use service container which enables to use the code functionalities multiple times in any place. Lack of such solution was visible in previous Drupal versions.

The truth is that for the experienced Drupal programmers, Drupal 8 is a big revolution, and some may have problems to adapt to the new, more modern environment. Even though Symfony components implementation is a way to standardize the coding processes and as a result, to make them more accessible.

Examples of Symfony components in Drupal 8

The main Symfony components used in Drupal 8 are:

  • Console
  • Dependency Injection (service container)
  • Event Dispatcher
  • Http Foundation
  • Http Kernel
  • Routing
  • Serializer
  • Translation
  • Validator

Symfony components possess the same functionalities as the framework itself – they provide scalability and flexibility. As mentioned, service container enables to reuse each function many times in the Drupal code. It vastly accelerates the app and its functionalities modification. Moreover, the service container helps debug, thanks to objects function determination.

Drupal Console – another important Symfony component

Drupal Console is the component made upon the Symfony Console. It is used for debugging and list of events creation. Thanks to dependency injection container usage, Event Dispatcher can provide access to all application events. To sum up – Drupal Console removes the border between Drupal and Symfony in terms of debugging.

Symfony version vs Drupal version

What distinguishes Symfony is a regular cycle of updates – every minor update (e.g. 3.3.) is released every 6 months. The new, major update – e.g. Symfony 3 is presented in 2-years episodes. As a result, each major version consists of five minor – 3.0, 3.1., 3.2., 3.3., 3.4. The whole Symfony roadmap is available there. It is worth to mention that there are nearly no differences between Symfony 3.4. and Symfony 4.0. The only thing that distinguishes them is that in Symfony 4.0. some functionalities were removed.

Which Symfony version is required by Drupal 8?

Drupal 8.5. requires Symfony 3.4. or higher, but not higher than 4.0, which means that 8.5 possess all the 4.0 features. The same is in the case of Drupal 8.6. That is why further Symfony updates will not have an enormous influence on Drupal – they will be based mostly on Symfony 3.4. Drupal 8 uses Symfony 3. However, the incoming Drupal 9 version will be based on either Symfony 4 or Symfony 5 version.

Drupal and Symfony – summary

As it is visible, Symfony components implementation into Drupal core was a beneficial solution for the content management system. Thanks to that, CMS is more business-oriented and provides better efficiency.

Wanna now more about Drupal?

Check our offer
Category: Drupal
Sebastian Zawadzki
Sebastian Zawadzki
Category: Drupal
Denis Peszka
Denis Peszka
Category: Drupal
Denis Peszka
Denis Peszka