The HTTP Kernel
The heart of Symfony. Takes a Request, dispatches lifecycle events, calls a controller, and returns a Response.
- The flow: `Request → kernel.request → controller resolved → kernel.controller → controller runs → kernel.response → kernel.terminate`.
- `kernel.request`: routing, security, locale, firewall checks happen here.
- `kernel.controller`: last chance to swap or wrap the controller (used by ParamConverters historically).
- `kernel.view`: only fires if the controller returned a non-Response (rare; e.g. with `#[Template]`).
- `kernel.response`: final pass at modifying the Response — add headers, cookies, profiling.
- `kernel.terminate`: runs after the response has been sent. Use for logging or async dispatch you do not want blocking the user.
- `kernel.exception`: catch any thrown exception and turn it into a Response.
Common gotchas
- Long-running work in `kernel.terminate` only blocks the next request on PHP-FPM if you re-use the worker. Use Messenger for true async.
- If your event listener returns a Response on `kernel.request`, no controller runs — that's how firewalls short-circuit unauthenticated requests.