9 Symfony Components to Anticipate in Drupal 8

symphony drupalAnother major release of Symfony’s fellow PHP framework Drupal 8 is underway. What’s interesting about it for Symfony developers is that the new Drupal release takes advantage of the great and functional Symfony components it has been missing, in order to provide its users with better development experience.

Let’s have a closer look at these components.

  • ClassLoader gives you tools for autoloading classes as well as caching the classes’ locations for performance. PHP uses the mechanism of autoloading to delegate loading of files which define classes when a class is referenced which hasn’t been included or required yet.
  • HTTPFoundation provides the HTTP specification with an object-oriented layer. It replaces PHP global functions and variables set by default by the object-oriented layer.
  • DependencyInjection allows for centralization and standardization of the ways of  objects’ construction and their passing to another ones by means of  constructor or your app’s methods.
  • Validator specifies the validation rules for the classes using PHP, XML, YAML, or annotations, to then be able to be checked against these classes’ instances.
  • EventDispatcher applies the Mediator Pattern by decoupling a Producer and a Consumer. The two maintain the communication with each other while independent from each other, but still can do it through the mediator.
  • HTTPKernel makes use of EventDispatcher to ensure a structured process of converting Request into Response.
  • Serializer is used for converting objects in specific format such as YAML, XML, JSON, and vice versa.
  • Routing (Drupal 8 implements the CMF Routing derived from Symfony Routing) is aimed at mapping HTTP requests to the combination of configuration variables to serve as arguments while passed from a URL to controller, and callback function.
  • YAML parses a YAML string and converts it to a PHP array. The other way around is also possible.

For Drupal developers, it’s going to be a fair shift in their usual development practices and they will definitely need some time to study and get used to such innovations. At the same time, Symfony developers will probably find that Drupal 8 is actually more familiar to them than they expected.