English 中文(简体)
Symfony - Architecture
  • 时间:2024-12-22

Symfony - Architecture


Previous Page Next Page  

Symfony is basically a collection of high quapty components and bundles. Components are collection of classes providing a single core functionapty. For example, Cache component provides cache functionapty, which can be added to any apppcation. Components are building blocks of a Symfony apppcation. Symfony has 30+ high quapty 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 apppcation 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 apppcation.

The relationship between the Components, Bundles, and Symfony apppcation is specified in the following diagram.

Architecture

Web Framework

Symfony is mainly designed to write high-quapty web apppcation with relative ease. It provides various options to write different types of web apppcation 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 −

    FrameworkBundle

    FrameworkExtraBundle

    DoctrineBundle

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 apppcation. Following is a simple workflow of Symfony web apppcation.

Web Apppcation

The workflow consists of the following steps.

Step 1 − The user sends a request to the apppcation 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.

Advertisements