The request lifecycle
This page follows one web request through Exponential, from index.php to the response, and names the class and file
of each step. It is the summary of The request lifecycle
in the kernel architecture standard; read that section when you change anything on this path.
Contents
- Before the kernel
- The kernel constructor
- The dispatch loop
- Output and shutdown
- Short cuts: who can answer first
- The same code outside a web request
- Rules for changes on this path
Before the kernel
- Maintenance and repair hooks. If
var/maintenance.jsonexists,expMaintenance::check()(kernel/classes/expmaintenance.php) may answer the request with the maintenance page. A request carryingexp_repairis handed toezpRepairQueue(lib/ezutils/classes/ezprepairqueue.php), which can repair an installation without its Composer libraries (Repair from the browser). - Autoload.
autoload.phploads the generated class maps:autoload/ezp_kernel.phpand the extension map written byphp bin/php/ezpgenerateautoloads.php -e. - Kernel object.
new ezpKernel( new ezpKernelWeb() ), then$kernel->run()->getContent().ezpKernelis a thin wrapper around a handler implementingezpWebBasedKernelHandler.
The kernel constructor
ezpKernelWeb (kernel/private/classes/ezpkernelweb.php), in order:
| Step | What happens |
|---|---|
| Settings | reads i18n.ini and site.ini, sets the time zone and file permissions, initializes eZSys |
| Global extensions | eZExtension::activateExtensions( 'default' ) |
| Siteaccess | eZSiteAccess::match() on the request URI, unless one was injected, then eZSiteAccess::change() |
| Siteaccess extensions | eZExtension::activateExtensions( 'access' ), and the INI instances are reset so siteaccess settings apply |
The dispatch loop
run() and dispatchLoop():
- Session and request initialization (
sessionInit(),requestInit()). - The events
request/preinputandrequest/input(Events, extension points and plugins). - URL translation: a URL alias or wildcard becomes a module address (
eZURLAliasML,eZURLWildcard);/About-usbecomes, for example,content/view/full/58. - The module check (
eZModule::accessAllowed()),fetchModule(), the siteaccess login check (theuser/loginpolicy) and the view access check (eZUser::hasAccessToView()). - Request rules, when configured, decide after URL translation and the policy check whether to allow, deny, redirect, rewrite or log (Request rules).
$module->run( $functionName, $params, ... )runs the view. A view can ask for a rerun with another URI or a redirect (eZModule::STATUS_RERUN,STATUS_REDIRECT); the loop handles both.
Output and shutdown
- The view's
$Resultis placed into the pagelayout (pagelayout.tplunless the view sets another), passed througheZDisplayResult()and the output filtersresponse/preoutputandresponse/output(kernel/private/classes/global_functions.php). shutdown()writes pending data. Under Velocity the worker is then reset for the next request (Velocity persistent workers).- Every request is classified once, whichever way it ends, and a not-found answer or a probe goes to its own log (Request logs).
Short cuts: who can answer first
| Who | When | Kernel started? |
|---|---|---|
| Browser or CDN | the page or file is still fresh in their cache | no request at all |
| Velocity response cache | a public page is cached in the server process | no |
| Role-aware HTTP cache | enabled, and a stored view matches the permission context | no (an early exit from config.php under PHP-FPM) |
| Maintenance hook | maintenance mode is on | partly (before the kernel) |
| Content view cache | a cached copy of this content view exists | yes, but the view is not rendered |
Details: Caching layers for engineers.
The same code outside a web request
Command line scripts and cronjobs do not use ezpKernelWeb: they boot through eZScript. The console
(bin/php/console) discovers commands; runcronjobs.php runs cronjob parts
(Console, cronjobs and background work).
Rules for changes on this path
- A change must keep working under PHP-FPM, Velocity and FrankenPHP.
- Code in
ezpKernelWebguards newer classes withclass_exists(), because a long-running Velocity worker may have loaded its class map before the class existed; new kernel hooks should do the same. - Per-request state must not live in static properties without a reset.
- No
exitfor flow control except througheZExecution::cleanExit().
Related pages
- Architecture overview
- Modules, views and access control
- Concurrency, statics and long-lived processes
- 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.