The life of a request

← The life of a request

Ashterix

docs(articles): Magento and Symfony examples side by side, request lifecycle as a Mermaid diagram

en/articles/magento-to-symfony/basics/lifecycle.md +15 āˆ’12

2 2
3 3 In Magento a request goes through the FrontController, the router list and the action's `execute()`. In Symfony `HttpKernel` follows the same path, but every step is an event anyone can subscribe to: routing, security, argument conversion, exception handling. Understand this diagram, and most of Symfony's "magic" becomes ordinary event listeners.
4 4
5 āˆ’ ```text
6 āˆ’ public/index.php
7 āˆ’ → Kernel::handle(Request)
8 āˆ’ → kernel.request RouterListener finds the route, then Firewall: who the user is
9 āˆ’ → kernel.controller
10 āˆ’ → ArgumentResolver Request, entities, DTOs
11 āˆ’ → Controller
12 āˆ’ returned a Response → kernel.response
13 āˆ’ returned a non-Response → kernel.view → kernel.response
14 āˆ’ threw an exception → kernel.exception → kernel.response
15 āˆ’ → Response::send()
16 āˆ’ → kernel.terminate
5 + ```mermaid
6 + flowchart TD
7 + A["public/index.php"] --> B["Kernel::handle(Request)"]
8 + B --> C{{"kernel.request"}}
9 + C -->|"RouterListener finds the route"| C2["Firewall: who the user is"]
10 + C2 --> D{{"kernel.controller"}}
11 + D --> E["ArgumentResolver: Request, entities, DTOs"]
12 + E --> F["Controller"]
13 + F -->|"returned a Response"| H{{"kernel.response"}}
14 + F -->|"returned something else"| G{{"kernel.view"}}
15 + G --> H
16 + H --> I["Response::send()"]
17 + I --> J{{"kernel.terminate"}}
18 + F -. "exception" .-> X{{"kernel.exception"}}
19 + X --> H
17 20 ```
18 21
19 22 | Symfony step | Closest in Magento | What happens there |