Symfony

Symfony: An Adaptable PHP Framework With A Strong Community

Posted by

In October 2015, the French software company SensioLabs published the open source Symfony framework, which had originally been developed under the name Sensio Framework. The unusual spelling of the new name is primarily due to an effort to maintain the subject and class prefix sf . The incentive for its creation was the launch, a year earlier, of Ruby on Rails and the desire of the developer team to have a comparable development platform for PHP projects . Since then, SensioLabs has continued the development of Symfony, adding in 2011, for example, a modular structure to Symfony 2.

What is Symfony?

Symfony is a collection of around 30 PHP libraries that can be downloaded and used as a pack or individually. Beyond the standard components, the framework also has additional modules that increase its scope or that can be used separately. According to information from SensioLabs, in the last decade there have been more than 500 million downloads of individual packs as well as the complete framework, which is reflected in its great global expansion. Many projects, such as the content management system Drupal , the web analysis tool Piwik or the software for creating online communities phpBB , are based on Symfony components. All framework packs are reusable and are available for download at no cost on the official project page .

Symfony: the web framework and its components

It is above all because of its modular design that Symfony serves as a development base for software development services of all types. Each module has its own function, but is not dependent on the other components, which provides this work environment with a high degree of flexibility and extensibility . So, for example, you can use Symfony as a full-stack framework if you need a wide range of functions for your web project or create your own Symfony libraries or even a lighter version of the framework. In this way you will adjust the components to the needs of your web application, regardless of whether it is a highly complex corporate project or a simple web page. At the same time, you always have the option to add or remove modules as you require.

Among others, this framework puts the following components at your disposal:

  • Asset – Module for generating URLs and versioning of image files, CSS stylesheets, and JavaScript applications.
  • ClassLoader : with it the own PHP classes are loaded automatically.
  • Debug – Provides PHP code debugging tools that find and classify errors.
  • DependencyInjection: Defines the rules for the production of objects for each web project.
  • EventDispatcher: These are the basic components that regulate the communication of individual modules in the form of events.
  • Form: Contains tools that help you easily create reusable HTML forms.
  • Templating: instruments for creating a template system.
  • Translation: module for the internationalization of the project.
  • Validator: allows you to validate the created classes.
  • Yaml: Load and save .yml files.

Advice

Did you know that Symfony and Laravel are among the most popular PHP frameworks? We show you why they are so good.

The model-view-controller for structuring your web application

Symfony allows you to implement the Model-View-Controller (MVC) principle. This architectural pattern classifies applications into three areas:

  • Data and core functionality (Model)
  • Visual representation of the generated data (View)
  • Processing user input (Controller)

The MVC approach guarantees clear and well-structured program code as well as high flexibility of the various components, which, thanks to this concept, can be shared and reused, as they are not tied to specific input data . However, at this point it should be noted that Symfony is not part of the MCV framework and does not contain any built-in model components . As a consequence, when you create a new Symfony project, it will lack the traditional models folder. With the help of additional ORM (Object Relational Mapper) libraries such as Doctrine , recommended by SensioLabs, or Propel you will be able to store objects in database systems on your own without any problems.

To create the presentation layer (View) of your web application, use the Templating module and create the respective templates that you can extend with the help of so-called Helpers (PHP objects). The Controller level uses the name index.php by default (you will find it in the “web” folder). As in other frameworks, in Symfony user inputs are also called “Actions”.

Symfony: PHP as a magnet for users

Symfony is a collection of different PHP libraries, so it is necessary to have said scripting language installed to be able to use the framework. The latest compatible version of the 2x Symfony 2.8 series requires at least PHP 5.3.9. Symfony 3.1 and 3.2 require PHP 5.5.9 or higher. From the beginning, the custom software development company aimed to create a collection of components for PHP projects that could compete with similar frameworks in other languages. Ruby on Rails particularly impressed developers, so for the establishment and maintenance of the individual components, they took as a reference the structure of the well-known Ruby framework.

The continued development and success of Symfony as a framework is closely tied to the history of the scripting language. Because it is available as an open source language and has always enjoyed great popularity in the scene, in recent years it has benefited from the joint work of several developers in its optimization . The great increase in performance, closely related to PHP 7 , suggests a positive impact on the performance of future web applications created with Symfony.

Backward compatibility and continuity with future versions

Since 2013, a new version of Symfony has been released every six months. Those users who have registered with SensioLabsConnect are promptly notified by email. Semi-annual updates to a new version sound, in principle, like something cumbersome and impractical for highly complex web applications. However, SensioLabs offers the appropriate solutions that guarantee the framework and developers the necessary continuity:

  • Backwards Compatibility – All Symfony updates since version 2.3 feature backwards compatibility. This ensures the functionality of the developed applications even when updated to a higher version. However, there are some exceptions where the promise of compatibility does not apply, including major releases like Symfony 3.0 (4.0, etc.).
  • Long-term support – Symfony releases are typically supported for 8 months. With the release of version 2.3, SensioLabs published the first edition of Symfony with long-term support (TLS). The duration of the versions with TLS is planned for two years and they guarantee updates for programming errors for 36 months and security patches for 48. In addition to the second scheduled TLS version, 2.7, version 2.8 was also equipped with support long-term.
  • “Continuous migration process” for version 3.0: The change to the latest major version of Symfony 3.0 is accompanied by the concept Continuous Upgrade Path. Symfony application developers can get detailed instructions for reviewing lines of code in versions 2.x and adapting them to the new specifications and then upgrading to the new version of the web application framework.

The advantages and disadvantages of Symfony as a framework

Searching for the right PHP framework is like finding a needle in a haystack: the desire to have powerful libraries for the chosen web language led to the development of numerous and diverse representatives suitable for various types of projects. Thanks to continuous progress, some of these frameworks (including Symfony) managed to convince a large number of PHP developers . This work environment especially excels in the structuring and operation of individual modules that facilitate the creation of various web applications , achieving, rightly, a great reception within the community. With long-term support releases and the general promise of high backward compatibility, the SensioLabs developer team has laid the right foundations to ensure the continuity of Symfony projects.

On the other hand, despite the assistance offered, the transition to new versions of the framework and the efforts related to adjustments in the code of the already developed application can become quite a tedious matter. In general, complexity is the big problem with most PHP work environments. Although you will find general documentation and specific explanations for each module, it is difficult for beginners to get familiar with this framework. Another weakness of Symfony is its performance, even compared to other PHP frameworks. Here, Doctrine’s generally accepted resource-intensive use of the ORM library plays an important role.

Who is the PHP component collection intended for?

All Symfony modules are characterized by the fact that they work both individually and in combination with others. In the latter case, however, it is not necessarily the standard pack, as it is also possible to create a micro work environment composed only of those elements necessary for your individual project . In this way, an overloaded library structure that goes far beyond the requirements of the project is avoided. On the other hand, Symfony is easily scalable and, using additional modules, it quickly adapts to the needs of the most demanding web projects. Thus, and as we have mentioned previously, this framework has not only served as the basis for numerous web applications (in whole or in part) but also for large-scale projects such as, for example, the online music streaming service Spotify. The website of the renowned fashion magazine Vogue is also among the beneficiaries of this PHP environment.

If you are working with PHP in a project that demands a high degree of flexibility , Symfony is the best alternative. However, in order to use the individual libraries correctly, advanced knowledge of this scripting language is necessary. It is essential that you have enough time to get to know the peculiarities of this framework and, finally, that you enjoy the benefits of web development with Symfony.

Leave a Reply

Your email address will not be published. Required fields are marked *