Symfony: changeable PHP framework with strong community
In October 2005, the French software company, SensioLabs published the open source framework, Symfony, which was actually developed under the name Sensio Framework. The unusual spelling of the new name resulted from preserving the old class prefix and theme prefix 'sf'. The reason for the framework was Ruby on Rails, which was released a year earlier, and the development team’s desire for a comparable development platform for PHP projects. Since then, SensioLabs has continuously developed the Symfony Framework. For example, in 2011 Symfony 2 added a modular design.
- What is Symfony?
- Symfony: Introduction to the components of web frameworks
- Model View Controller concept for structuring web applications
- Symfony: PHP as a user magnet
- Downward compatibility and LTS versions promise continuity
- The advantages and disadvantages of the Symfony Framework
- Who is the PHP component collection suitable for?
What is Symfony?
Symfony is a collection of around 30 PHP libraries that can be downloaded and used both as a package or individually. Apart from these standard components, there are additional modules that can be used to extend the framework or used separately. According to SensioLabs, more than 500 million downloads of individual packages and complete frameworks have been recorded over the past ten years, which is reflected in the general distribution: numerous projects such as the Drupal Content Management system, the web analysis tool, Piwik and forum software phpBB rely on Symfony components. All packages from this framework are reusable and available for free download on the official website.
Symfony: Introduction to the components of web frameworks
The fact that Symfony can be used as a development basis for web projects of all kinds is due to its modular structure. Each module has its own function, but does not rely on other components, which then gives the framework a high degree of flexibility and expandability. You can use Symfony as a full-stack framework if you need a very broad range of functions for your web project. In addition, you can create your own Symfony library set or create a slim version of the framework. In this way, you can tailor the components to the precise requirements of your web application – whether it is a complex enterprise project or a simple website. At the same time, you always have the option to add or remove modules as the framework conditions change.
You can choose from the following standard components:
- ClassLoader: ClassLoader ensures that your own PHP classes are loaded automatically.
- Debug: provides tools for debugging PHP code in order to locate and classify errors.
- DependencyInjection: enables you to define standards for creating objects for the respective web project.
- EventDispatcher: elementary component that controls the communication of individual modules in the form of events.
- Form: contains tools that you can easily use to create reusable HTML forms.
- Templating: tools for creating a template system.
- Translation: module for internalising the project.
- Validator: enables you to validate created classes.
- Yaml: loads and saves .yml files.
Model View Controller concept for structuring web applications
Symfony enables the implementation of the Model View Controller approach (MVC). This architecture pattern divides applications into three areas
- Data and core functionality (model),
- Visual presentation of generated data (view)
- Processing user inputs (controller).
The MVC concept provides a clear, well-structured program code and a high degree of flexibility for different components, which can be exchanged and reused depending on the concept, since they are not tied to concrete input data. At this point, however, it needs to be said that Symfony does not belong to the proclaimed line up of MVC frameworks and does not contain an integrated model component. If you create a new Symfony project, the typical model folder will also be lacking. Using additional ORM (Object Relational Mapper) libraries, such as the Doctrine, recommended by SensioLabs, or Propel, you can implement object storage in database systems yourself.
To create the presentation layer (view) of your web application, use the template module and create corresponding templates, which can be expanded using the so-called helper (PHP objects) and specific functions. The controller level is named index.php (can be found in the 'web' folder). The user inputs are named 'actions' in Symfony, just like they are in many other frameworks as well.
Symfony: PHP as a user magnet
Symfony is a collection of various PHP libraries, which is why you must have the script language installed in order to use the framework. For the current supported version of the 2.x series Symfony 2.8, you need PHP 5.3.9 or higher. Symfony 3.1 and 3.2 require PHP 5.5.9 or higher. From the beginning, the SensioLands developer teams had the goal of creating a component collection for PHP projects that could compete with comparable frameworks in other languages. In particular, Ruby on Rails impressed the French developers, which is why they decided to make the individual components similar to the structure of the popular Ruby framework.
The development and success of the Symfony Framework is therefore closely tied to the history of the script language. Since this is freely available as an open source language and has always been popular, various developers have optimised it in recent years. The strong performance increase linked to PHP7 also has a positive impact on the performance of future Symfony web applications.
Downward compatibility and LTS versions promise continuity
A new version of Symfony has been released every six months since 2013. Users who have registered with the SensioLabsConnect community are kept up-to-date with e-mails. Upgrading the framework every six months to a higher version initially sounds like a very tedious and impractical task for complex web applications. SensioLabs, however, provides the right solutions so that the framework and the developed applications have the necessary continuity:
- Backward compatibility: all Symfony updates (since version 2.3) have been characterised by backward compatibility. This means that the developed applications are guaranteed to still function when switching to higher versions. However, there are some exceptions for which the unrestricted Compatibility Promise doesn’t apply. In addition, major releases such as Symfony 3.0 (4.0, etc.) are excluded from the warranty.
- Long-term support: Symfony versions are usually supported for eight months. With the 2.3 version, SensioLabs released the first edition of Symfony with long-term support (LTS). These LTS versions are planned for every two years and provide 36 months of updates for program errors and 48 months of security patches. In addition to the scheduled second LTS version 2.7, the following version 2.8 was also equipped with the extended support period.
- 'Continuous Migration Process' for 3.0: when switching over to the last major version, Symfony 3.0, the development team accompanies you while using the Continuous Upgrade Path concept. As a Symfony application developer, you can receive detailed tips for revising lines of code in 2.x versions, gradually adapting them to the new specifications. You can then upgrade to the new version of the web application framework.
The advantages and disadvantages of the Symfony Framework
Searching for the appropriate PHP framework in the past was like looking for a needle in a haystack: the desire for a powerful library set for the popular web language led to the development of numerous representatives, which were quite different for different project types. However, a few frameworks – including Symfony – have managed to impress a large number of PHP developers, thanks to its continuous progress. The framework scores especially well when it comes to structuring and linking individual modules, which can be used to implement various web applications, contributing to it being highly rated by the community. With long-term support versions and the general promise of providing the highest possible level of backward compatibility, the SensioLabs development team also provides the right foundation to ensure that the Symfony project can continue.
Nevertheless changing to a new version of the framework and the adjustments associated with the code of the developed Symfony application is sometimes a rather tedious matter. And that is despite the fact that assistance is offered. Complexity is also generally a big problem of the PHP framework. Although there is plenty of information and lots of explanations for each module, beginners could find it difficult to familiarise themselves with the framework. The Symfony Framework also reveals weaknesses in performance – even in comparison to other PHP frameworks. The use of the resource-intensive ORM library doctrine also plays an important role here.
Who is the PHP component collection suitable for?
All Symfony modules are characterised by the fact that they work individually as well as in a network. The latter does not have to be the standard framework bundle: you can also create your own micro-framework, which is compiled only with the components you choose. In this way, you avoid having to work with an overloaded library structure that goes far beyond the requirements of the developed project. But Symfony is also scalable in the other direction and can be quickly converted into a basic design for demanding web projects with additional modules. It’s not only the above-mentioned applications (complete or partial) that are based on Symfony, but also the website of the music streaming service, Spotify. The French website of fashion magazine, Vogue, also benefits from using the PHP framework.
The Symfony Framework is the right choice for you if you want to work with PHP and have a high degree of flexibility. In order to use the individual libraries correctly, however, you need to know more than just the basics of the script language. So plan some time to get to know the features of the framework and then take advantage of all the benefits of developing with Symfony.