Propeople Blog

A regular dose of fresh news, events, products, Drupal development resources and more.

April 18, 2012

Symfony 2 Meets Drupal 8

Drupal has evolved into a powerful content management system over the years, becoming more and more complex. Luckily there is always a chance to improve it and here Symfony 2 comes into the picture. 
Because of Drupal becoming more complicated since its beginnings, it has become a little bit of a challenge for people that just started using it. Complexity is often feared by big software projects, as well as by developers that use it. 
There is too much custom code that can be found in the core of Drupal, and due to the fact that standardized patterns and components are rarely used, it is often hard for both experienced PHP developers and novices in the subject to understand it at its full. Dries Buytaert – the inventor of Drupal states that one good approach is by using standardized patterns and components. 
The Internet is mostly heading towards web services lately, going mobile. This sets new rules and expectations for Drupal and all the other content management systems, bringing out the need for more flexible page and layout capabilities. Luckily the Drupal community of developers has thought about this, coming up with ideas on how to improve it. One of them is by collaborating with fellow developers, in this case we are talking about Symfony 2
Symfony 2.0 is a company that provides web services which is MIT licensed and GPL compatible. It offers a reusable set of standalone PHP components that solve big web development issues when it comes to coding. Drupal 8 is adapting some of Symfony 2’s components that will definitely help the Drupal community build a more powerful and flexible system that would be less complicated to master. 
You can find the full list of components provided by Symfony 2 in Drupal 8 in the presentations at Drupalcon events, but here is just some of them:
- drupal_set_message() could be replaced by Symfony 2 “flash message” which is a feature that passes messages to the very next request. This is done quicker than the older version in Drupal. Although this component is not yet fully compatible with Drupal 8, they are seriously working on it on order to make it happen until its launch.
- The ClassLoader Component is another potential component to be found in Drupal 8. It loads your project classes automatically if they follow some standard PHP conventions which will be adopted by Drupal soon. Whenever you use an undefined class, PHP uses the auto loading mechanism to delegate the loading of a file defining the class. Symfony2 provides a "universal" autoloader, which is able to load classes from files that implement a set of conventions. You can find more information about this component on Symfony 2 website.
- HTTP Foundation is another very important Symfony 2 component to be interated with Drupal 8. The HttpFoundation Component defines an object-oriented layer for the HTTP specification. In PHP, the request is represented by some global variables ($_GET, $_POST, $_FILE, $_COOKIE, $_SESSION...) and the response is generated by some functions (echo, header, setcookie, ...). The Symfony2 HttpFoundation component replaces these default PHP global variables and functions by an Object-Oriented layer.
- Routes will be a component used by Drupal 8, but with several modifications for it to be compatible.
- Event Dispacher
- HTTP Caching
- and more to come
There is still much place for discussions about this collaboration and many others to come, so that you are more then welcome to join the discussion. We will keep you posted with other fresh news as we find out about them.

0 Responses to this post

Communicate!