Appearance
Request Lifecycle
How an HTTP request travels through Apache, admin/engine.php, LimsRouter, and Angular Fusion — and how modern modules differ from legacy PHP pages.
1. Entry & bootstrap
- Apache
.htaccessrewrite (system.phpcheckHtAccess()): Maintains root.htaccessandadmin/.htaccessso non-fileadmin/*routes enteradmin/engine.php, static assets are served directly, and.pdf/.csv/.json/.txtfiles route throughfilecheck.php. admin/engine.phpbootstrap: Loadssystem.php(session_start,.env,validateLogin(), HTMLPurifiercleanPOST()),include.php→sqlLib→DatabaseManager::connect(),AccessControl, andFusion::configure().
2. Two request lanes (LimsRouter::appRequestFile())
Before rendering the legacy LIMS page chrome, admin/engine.php checks LimsRouter::appRequestFile() and branches into one of two lanes:
| Lane | Trigger | What happens |
|---|---|---|
| App Request (fast lane) | X-App-Request: true header (all Fusion navigations & AJAX calls) or ?raw=1 (file downloads) | Skips the LIMS HTML shell, returns 401 if unauthenticated or 404 if no module file matches, requires the module's index.php, and exits cleanly so raw HTTP status codes, JSON, or binary bytes reach the client untouched. |
| Full Page Load | Initial browser navigation or refresh | Renders the LIMS frame (header, sidebar, desk), buffers the module's output into #mainBody, and boots the Angular shadow-root app (admin/app.ts). |
Once the Angular app has booted, every <a fusionLink>, navigate(), postForm(), postFields(), and ajaxAction() call sends X-App-Request: true and stays in the fast lane with zero full-page reloads.
3. Inside LimsRouter::render()
Every modern module's index.php calls (new LimsRouter(...))->render(), which wraps the request in a consistent pipeline:
- Platform schemas: Ensures
LimsFlagsandLimsFileStoragetables exist before opening a transaction. - Input normalization (
plainText()): Decodes the HTML entities added bysystem.php'scleanPOST()and normalizes empty$_POSTstrings intonullso PHP DTOs receive real values. - Single DB transaction: Opens one MySQL/MariaDB transaction for the request (skipped on
?feature=migrationsbecause DDL auto-commits). - Routing & DI: Matches
?feature=and?action=to the controller method, autowires constructor dependencies (DatabaseManager,CurrentUser, services, repositories), and hydrates/validates any#[DataObject]parameter (returning422on invalid input). - Commit or rollback: Commits automatically on any
2xxresponse, or rolls back every write on status>= 400or any uncaught exception. - Error translation: Converts
HttpException(403,404,409) into{"message": "..."}JSON on app requests or an alert banner on full page loads.
4. Built-in safeguards & Master notices
Master user health notices
On full-page GET requests returning 200, LimsRouter prepends warning banners above the page for Master users whenever the module (or any submodule) has pending migrations, schema drift (STATE=LOCAL), or out-of-sync access_config.php / flag_config.php files. On uncaught exceptions, those notices are also attached to the error page so a missing table never strands a Master user.
- Double-submit guard: At the end of
system.php, any form submitting atoken_lock_guidthat has already been processed has its$_POSTcleared. - Legacy modules: Plain-PHP legacy modules bypass
LimsRoutercompletely — they do not get automatic transactions,plainText()decoding, DTO validation, or automatic rollback.
Next: see how code is structured inside a module in Module Architecture.