A framework is aimed at reducing the development time without the need to sacrifice maintainability, scalability, or quality. Symfony can take less than a day to learn, comes with many tools and classes, and is easy to install. This means the developer can spend more time developing the application. All of these reasons and many more are why Symfony has come about, and why it has maintained its place as one of the best PHP5 frameworks.
The current trends at the moment seem to revolve around agile development methodologies with groups of developers working on the same web application. Using the Symfony framework, developers are aided in writing structured and maintainable code. This is all down to the framework's strict implementation of the Model-View-Controller (MVC) paradigm and modulization.
The Model-View-Controller pattern
Many books go into the details of what the MVC pattern is and how it works. However, we will just look at the basic overview and how Symfony incorporates the pattern.
The MVC pattern is designed to split the presentation and business logic, and has a controller that manages the user's interactions between the two.
When you first use Symfony to generate the skeleton code for a new application and module, you can see exactly how Symfony strictly abides by the MVC pattern.
The controller is responsible for processing user events. The controllers in Symfony are split into several components.
1. It is the entry point into the application.
2. It determines what action is required to execute.
3. Loads the configurations.
4. Executes the filters.
One great feature about the controller being the entry point is that any time a site needs to go down for maintenance, the controller can simply be disabled. Creation of a new application in Symfony creates two controllers:
The difference between the two is the debug information and error displaying.
The controller calls an action, which is what drives the application. The action contains all of the application logic and has the ability to access everything from the request, sessions, authentication, and core Symfony objects.
The model layer represents the applications data and the business rules used to manipulate and access it.
Symfony's model layer is split into two separate layers—an Object Relational Mapping (ORM) layer and a data abstraction layer. Of course, there are a few good PHP5 ORM and database abstraction libraries that already exist. Therefore, rather than reinventing the wheel, the framework incorporates the Doctrine ORM (http://www.doctrine-project.org/) which is the defualt ORM layer, with the option of using the Propel ORM (http://propel.phpdb.org). The second layer, being the data abstraction layer is handled by PHP Data Objects (PDO).
Database abstraction means database portability. Every database vendor will have a slight variant in their SQL syntax. Therefore, by moving your application to another RDBMS, a developer would have to amend certain queries. But with a database abstraction layer, this portability becomes transparent.
Object relational mapping turns database tables, rows, and different variable types into objects. As Symfony is written using OOP, it makes sense that the data is returned as an object.
At the moment, Symfony comes shipped with Propel 1.2 as it's default ORM. However, this whole ORM layer can be easily changed. For example, the ORM layer can be changed to Doctrine (http://www.phpdoctrine.org/).
A view, which is commonly referred to as a template, is displayed to the user. These templates are completely separated from controllers and models. They mainly comprise of XHTML markup and presentation logic in the form of PHP tags. Although Symphony's template system has matured, the view layer can be replaced with another template engine, such as Smarty (https://smarty.php.net) through a plugin, for example.