Web Framework Internals interview question · Most asked
Describe Symfony's HttpKernel lifecycle and how listener priorities affect it.
Summary
The kernel dispatches kernel.request (session, routing, locale, firewall and your listeners; any may set a response), kernel.controller and kernel.controller_arguments, runs the controller, kernel.view for non-Response results, kernel.response, kernel.finish_request, sends the response, then kernel.terminate; kernel.exception handles errors. Listeners run from highest to lowest priority, and setting a response stops later listeners.
Longer Answer
A maintenance listener with default priority runs after routing and the firewall, so visitors get a 404 or login redirect instead of the maintenance page; give it a higher priority. Inspect the order with bin/console debug:event-dispatcher kernel.request.
Key Points
- Events: request, controller, controller_arguments, view, response, finish_request, terminate, exception.
- Higher priority runs first.
- Setting a response short-circuits.
- Inspect with debug:event-dispatcher.
Deep dive: Request Lifecycle: Symfony's HttpKernel and Kernel Events
Explanation
What interviewers look for
Event order and a priority example.
More most-asked Web Framework Internals questions
- What is a request lifecycle, and why should a backend engineer know it for their framework?
- What layers does a request pass through before reaching application code, and how should their timeouts relate?
- How does Express handle a request, and how are errors routed?
- What is the NestJS request lifecycle?
- Describe the Spring MVC request flow and where exceptions are handled.
- Where should authentication, authorisation, validation and error formatting live in a web framework?
- Walk through the Laravel request lifecycle and say where you would add code that must run on every request.
- Walk through the Django request lifecycle.