Symfony is basically a collection of high quality components and bundles. Components are collection of classes providing a single core functionality. For example, Cache component provides cache functionality, which can be added to any application. Components are building blocks of a Symfony application. Symfony has 30+ high quality components, which are used in many PHP framework such as Laravel, Silex, etc.
Bundles are similar to plugin but easy to create and easy to use. Actually, a Symfony application is itself a bundle composed of other bundles. A single bundle can use any number of Symfony component and also third-party components to provide features such as Webframework, database access, etc. Symfony core web-framework is a bundle called FrameworkBundle and there is a bundle called FrameworkExtraBundle, which provides more sophisticated options to write a web application.
The relationship between the Components, Bundles, and Symfony application is specified in the following diagram.
Symfony is mainly designed to write high-quality web application with relative ease. It provides various options to write different types of web application from simple web site to advanced REST based web services. Symfony provides web framework as separate bundles. The common bundles used in Symfony web framework are as follows −
Symfony web framework is based on Model-View-Controller (MVC) architecture. Model represents the structure of our business entities. View shows the models to the user in the best possible way depending on the situation. Controller handles all the request from the user, does the actual work by interacting with Model and finally provides the View with the necessary data to show it to the user.
Symfony web framework provides all the high-level features required for an enterprisegrade application. Following is a simple workflow of Symfony web application.
The workflow consists of the following steps.
Step 1 − The user sends a request to the application through the browser, say http://www.symfonyexample.com/index.
Step 2 − The browser will send a request to the web server, say Apache web server.
Step 3 − The web server will forward the request to the underlying PHP, which in turn sends it to Symfony web framework.
Step 4 − HttpKernel is the core component of the Symfony web framework. HttpKernel resolves the controller of the given request using Routing component and forward the request to the target controller.
Step 5 − All the business logic takes place in the target controller.
Step 6 − The controller will interact with Model, which in turn interacts with Datasource through Doctrine ORM.
Step 7 − Once the controller completes the process, it either generates the response itself or through View Engine, and sends it back to the web server.
Step 8 − Finally, the response will be sent to the requested browser by the web server.