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

← All Web Framework Internals questions