The request lifecycle
This page is for developers who want to know where their code runs on a web request, the way they know Symfony's
HttpKernel events, Laravel's middleware pipeline or Django's request and response cycle. The authoritative
description is The request lifecycle in the kernel architecture;
this page walks through it with framework eyes.
Contents
- The steps
- The same steps as a pipeline
- Where you can hook in
- Under persistent workers
- Command line requests
The steps
index.php. Ifvar/maintenance.jsonexists,expMaintenance::check()may answer (maintenance mode). A request carryingexp_repairis handed toezpRepairQueue. Thenautoload.phploads Composer's autoloader and the generated class maps,config.env.phpandconfig.phpare read, and$kernel = new ezpKernel( new ezpKernelWeb() ); echo $kernel->run()->getContent();runs the request.- Kernel construction.
ezpKernelWebreadsi18n.iniandsite.ini, activates the global extensions, matches the siteaccess witheZSiteAccess::match()on the request URI and host, switches to it witheZSiteAccess::change(), activates the siteaccess's extensions and reloads the settings so the siteaccess layer applies (Siteaccesses). - Session and request initialization (
sessionInit(),requestInit()), then the eventsrequest/preinputandrequest/input. The CSRF check ofezformtokenis arequest/inputlistener. - URL translation. A URL alias (
/About-us) becomes a system address (content/view/full/58) througheZURLAliasML; URL wildcards are applied througheZURLWildcard(Pretty URLs). - Module lookup and access checks. The module must exist in a module repository and be allowed
(
eZModule::accessAllowed()); the siteaccess login check (user/loginpolicy) and the view's policy functions (eZUser::hasAccessToView()) run before the view. Request rules decide after the alias translation and after the policies allowed the view (Middleware: request rules). - The view runs.
$module->run( $functionName, $params, ... )executes the view script orModuleViewclass, which returns a$Resultarray. A view can ask for a rerun with another URI or a redirect (eZModule::STATUS_RERUN,STATUS_REDIRECT); the dispatch loop handles both (Controllers). - Page layout and output. The result's
contentis placed into the siteaccess'spagelayout.tpl(unless the view chose another or none), passed through the output filtersresponse/preoutputandresponse/output, and returned.ezformtokenadds its hidden token to forms in aresponse/outputlistener. - Shutdown. Pending data is written; under Velocity the worker resets its state for the next request.
The same steps as a pipeline
| Concern | Symfony | Laravel | Django | Exponential |
|---|---|---|---|---|
| Entry | public/index.php, Kernel::handle() | public/index.php, HTTP kernel | WSGI or ASGI handler | index.php, ezpKernel::run() |
| Early answer | kernel.request listener | global middleware | middleware | maintenance check, HTTP cache early exit, Velocity response cache |
| Tenant or site | host requirement, custom listener | domain routes | Site framework | siteaccess matching |
| Routing | router | router | URLconf | URL alias and wildcard translation, then <module>/<view> |
| Authorization before the action | firewall, voters | auth and can middleware | decorators | view functions, siteaccess login check, request rules |
| Action | controller | controller | view function | module view |
| Rendering | Twig | Blade | templates | template language and pagelayout |
| Response filter | kernel.response | terminable or after middleware | middleware | response/output filter |
Where you can hook in
| Need | Hook | Read |
|---|---|---|
| Answer or refuse before routing | request/preinput or request/input listener | Events and listeners |
| Deny, redirect, rewrite or log by rule after the alias is known | request rules | Middleware |
| A new address | a module and a view in your extension | Routing |
| Change a kernel view | a view class re-implementation (site.ini [RunnableSettings] Implementation[]) or a module override | Controllers |
| Change the final HTML | response/output filter listener | Events and listeners |
| Run around content operations | workflows and triggers | Workflows |
Under persistent workers
Under Velocity the application is loaded once in a parent process and forked into workers that each serve many
requests. Steps 2 to 8 run per request, but anything a class keeps in a static property survives into the next request
unless it is reset. The kernel's rules: no per-request state in statics without a reset, no exit for flow control
except through eZExecution::cleanExit(), and a changed class or setting reaches the workers only after
./console exp:velocity restart or exp:velocity deploy
(Servers: Velocity, PHP-FPM and FrankenPHP).
If you know Laravel Octane or Symfony on RoadRunner, the discipline is the same.
Command line requests
Console commands, cronjob parts and queue workers do not use ezpKernelWeb. They boot through eZScript, which
loads settings for the siteaccess given with -s, and run as the anonymous user unless the code logs a user in
(Command line).
Related pages
- Architecture for application creators
- Front controller pattern
- Velocity: the persistent-worker server
- Free documentation: this page is free to copy, translate and improve under the GNU FDL 1.3.
Become an Exponential Partner
Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.