D11 Pipeline: HTTP Foundation & Middleware
Phase ①
HTTP Foundation & Middleware Stack
The entry point of every request: from raw PHP globals through Symfony's HttpKernel and Drupal's middleware chain.
Incoming HTTP Request (Browser / CLI)
Front Controller
index.php
The single entry point for all web requests. Bootstraps the autoloader
(
Also handles
(
autoload.php), instantiates DrupalKernel, and calls handle().Also handles
$request = Request::createFromGlobals() via Symfony HttpFoundation.Drupal Application Kernel
DrupalKernel::handle()
Subclass of Symfony's
— booting the service container (DI container)
— loading module service providers and tagged services
— discovering and caching service definitions
— passing control to
Kernel. Responsible for:— booting the service container (DI container)
— loading module service providers and tagged services
— discovering and caching service definitions
— passing control to
StackedHttpKernela
Service Container Boot
Compiles or loads cached container. Registers all module & core services. Sets up tagged service collections.
b
Build StackedHttpKernel
Uses
http_middleware tagged services to construct the middleware stack via StackedKernelPass.Symfony / Drupal Middleware
StackedHttpKernel — Middleware Chain
Request passes down through middleware, response passes back up. Each middleware can short-circuit and return a response early.
Middleware layers (outer → inner)
ReverseProxyMiddlewareTrusted proxy / X-Forwarded-For
PageCacheFull-page anonymous cache (Internal Page Cache)
NegotiationMiddlewareContent negotiation headers
AjaxPageStateStrips stale asset library info
HttpsRedirectMiddlewareHTTP → HTTPS if configured
HttpKernel (core)Symfony HttpKernel — innermost
Cache hit path
If PageCache middleware finds a valid cached response for the request (anonymous user, cacheable route), it returns the Response immediately — the rest of the pipeline below is never reached for that request.
Drupal 11
Middleware priority is set via priority tag on service definitions. D11 removed deprecated drupal_static()-based bootstrap phases in favour of the service container. The PageCache middleware now integrates more tightly with the cache.page bin and cache tag invalidation.
Symfony Core
HttpKernel::handle()
Symfony's event-driven HTTP kernel. Dispatches a series of kernel events
to which Drupal (and contrib) subscribe. The events below run in order.
to which Drupal (and contrib) subscribe. The events below run in order.
1
KernelEvents::REQUEST
Route matching, authentication, dynamic page cache lookup, language negotiation. → continues to Phase ②
2
KernelEvents::CONTROLLER
Subscribers may substitute a different controller. Access checking is enforced here by
AccessAwareRouter.3
Controller invoked
Returns a
Response object or a render array. → continues to Phase ②/③4
KernelEvents::VIEW (if render array)
Triggered when controller result is not a Response. → continues to Phase ③
5
KernelEvents::RESPONSE
Response alter / Dynamic Page Cache store. Headers set, response sent.
6
KernelEvents::FINISH_REQUEST + kernel.terminate
Cleanup after response is sent. Async tasks (e.g. cron, queue workers via
kernel.terminate).→ Phase ② Routing & Controller