Skip to content

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.

BrowserFull page load, or a Fusion fetch (X-App-Request / ?raw=1)HTTPApache .htaccess rewriteadmin/* that is not a real file → admin/engine.phpStatic assets as-is.pdf/.csv → filecheck.phpadmin/engine.php bootstrapsystem.php: session_start, .env, validateLogin()cleanPOST(): HTMLPurifier over $_GET / $_POSTinclude.php → sqlLib → DatabaseManager::connect()AccessControl setup · Fusion::configure()No valid session→ login.phpLimsRouter::appRequestFile()X-App-Request header or ?raw=1?yesnoApp requestNo LIMS layoutNot logged in → 401No module file → 404require file, then exitFull page loadHead, header, sidebar menumoduleFile() or home.phpob_start → require filestripContent → #mainBodyModule fileadmin/{folder}/{module}/View → index.phpLegacy moduleplain PHP, echoes HTMLnew-structure modulenew LimsRouter(...)->render()1 ensureSchema(): flag + file storage tables2 plainText(): decode input, blank POST → null3 BEGIN transaction (not on ?feature=migrations)4 dispatch → controller action (bad DTO → 422)5 COMMIT, or ROLLBACK on status ≥ 400 / throw6 HttpException → alert HTML or {"message"} JSONCore servicesRepositoriesMySQL (PDO)ResponseHTML page · FusionResponse · JSON · file downloadFusion pages: navigate() · ajaxAction() · postForm() send X-App-Request

1. Entry & bootstrap ​

  1. Apache .htaccess rewrite (system.php checkHtAccess()): Maintains root .htaccess and admin/.htaccess so non-file admin/* routes enter admin/engine.php, static assets are served directly, and .pdf/.csv/.json/.txt files route through filecheck.php.
  2. admin/engine.php bootstrap: Loads system.php (session_start, .env, validateLogin(), HTMLPurifier cleanPOST()), include.php → sqlLib → DatabaseManager::connect(), AccessControl, and Fusion::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:

LaneTriggerWhat 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 LoadInitial browser navigation or refreshRenders 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:

  1. Platform schemas: Ensures LimsFlags and LimsFileStorage tables exist before opening a transaction.
  2. Input normalization (plainText()): Decodes the HTML entities added by system.php's cleanPOST() and normalizes empty $_POST strings into null so PHP DTOs receive real values.
  3. Single DB transaction: Opens one MySQL/MariaDB transaction for the request (skipped on ?feature=migrations because DDL auto-commits).
  4. Routing & DI: Matches ?feature= and ?action= to the controller method, autowires constructor dependencies (DatabaseManager, CurrentUser, services, repositories), and hydrates/validates any #[DataObject] parameter (returning 422 on invalid input).
  5. Commit or rollback: Commits automatically on any 2xx response, or rolls back every write on status >= 400 or any uncaught exception.
  6. 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 a token_lock_guid that has already been processed has its $_POST cleared.
  • Legacy modules: Plain-PHP legacy modules bypass LimsRouter completely — 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.

Labmin LIMS Module Developer Documentation