Request lifecycle
Same physics as the PHP tutorial - request in, response out. Symfony runs an HttpKernel + event pipeline before your controller.
The spine
Comments for the flow above:
public/index.phpstill requires Composer autoload - nothing magical- Kernel events = the wrappers you sketched as stretch goals on the mini-router (Symfony's "middleware" flavor)
- Router match is your
{name}patterns grown up - Response can be Twig HTML, JSON, redirect, file download…
Compared to the mini-router
php
// your toy version
$response = $router->dispatch($method, $path);
$response->send();Symfony:
- Creates a
Requestfrom globals ($_GET,$_SERVER, …) via HttpFoundation - Dispatches kernel events (
kernel.request,kernel.controller, …) - Resolves the controller + arguments (route params, services)
- Calls your action, wraps the return value into a
Response - Sends it
You don't call echo and header() by hand anymore - return values / helpers do that.
Where "magic" actually is
- Service container builds controller dependencies and argument resolvers
- Event subscribers do session start, locale, security, etc.
- Doctrine lazy-loads associations if you aren't careful (we cover N+1 later)
- Twig compiles templates to PHP under
var/cache
Once you see it as boot → events → route → action, Symfony code reviews get much calmer.
Next: declaring routes without writing a regex engine.
Best,
-- ł.