Skip to content

LIMS Platform (LIMS\Platform) ​

Shared foundation layer in admin/Platform/ (LIMS\Platform\). Copied unchanged from lims-demo into any Labmin LIMS.

LimsRouter ​

Extends Labmin\Router\Router with LIMS defaults, automatic transactions, input normalization, app-request handling, and built-in Master admin pages.

php
new LimsRouter(
    string $moduleDirectory,        // Usually __DIR__ of the module's index.php
    string $default,                // Default controller class when ?feature= is omitted
    array $controllers = [],        // Additional controllers (module + submodules)
    ?callable $onValidationError = null,
    array $providers = [],          // Extra DI providers beyond DatabaseManager & CurrentUser
)

Methods ​

MethodDescription
render(): voidEnsures flag & file-storage schemas, decodes $_GET/$_POST (plainText()), opens one DB transaction (except ?feature=migrations), dispatches, commits on 2xx or rolls back on error/4xx, converts HttpException into JSON or alert HTML, and attaches Master health notices on full GET 200 loads (and error pages).
LimsRouter::isAppRequest(): boolReturns true when HTTP_X_APP_REQUEST is non-empty or $_GET['raw'] === '1'.
LimsRouter::appRequestFile(): ?stringCalled by admin/engine.php before layout output. Returns the target PHP file to require on app requests (exiting with 401 if logged out or 404 if not found), or null for normal page loads.
LimsRouter::moduleFile(): ?stringResolves /admin/{folder}/{module}/View → index.php and /admin/{folder}/{module}/{file} → {file}.php.

Built-in Master routes ​

Registered automatically whenever CurrentUser::fromSession()->isMaster() is true:

  • ?feature=migrations — MigrationController (generate and editSeeds enabled only when STATE === 'LOCAL')
  • ?feature=access — AccessConfigController (module + all submodules)
  • ?feature=flags — FlagConfigController (module + all submodules)

CurrentUser ​

Injected automatically into controllers and services by LimsRouter.

MemberType / SignatureDescription
CurrentUser::fromSession()selfBuilds from $_SESSION['loggedin'].
$idintusers.id (0 if not logged in).
$namestringLogged-in username.
$personnelId?intLinked personnel.id, or null.
isLoggedIn()boolWhether a valid user session exists.
isMaster()boolWhether the user has Master access.
can(string $module, string $action)boolChecks an access_config.php action via AccessControl::canDo().
hasFlag(string $module, string $flag)boolChecks a flag_config.php flag via LimsFlags.

Repository ​

Abstract base class for module repositories (public function __construct(protected readonly DatabaseManager $db)).

Protected methodReturnPurpose
one(string $class, string $sql, array $params = [])?objectHydrates the first row into a #[DataObject] or #[Table] class, or null.
many(string $class, string $sql, array $params = [])list<object>Hydrates every row into $class.
rows(string $sql, array $params = [])list<array<string, mixed>>Raw associative rows.
value(string $sql, array $params = [])mixedFirst column of the first row, or null.
run(string $sql, array $params = [])intRuns INSERT/UPDATE/DELETE; returns insert ID or affected rows.
insert(object|string $schema, ?array $data = null)intValidated MaterializeMySql::insert(). Returns generated ID.
update(object|string $schema, ?array $data = null)intValidated MaterializeMySql::update(). Requires primary key(s).
self::placeholders(array $values)stringBuilds "?, ?, ?" for SQL IN (...) lists ("NULL" when empty).
self::hydrate(array $row, string $class)objectMaps SQL columns (and #[Column(column: ...)] aliases) onto $class, cleaning '' and '0000-00-00' to null for nullable properties.

Platform Wrappers ​

  • LIMS\Platform\FileStorage\LimsFileStorage — Extends Labmin\FileStorage\Services\FileStorage, wired automatically to DatabaseManager, .env FILE_STORAGE_ROOT, and CurrentUser. Static ensureSchema() runs in LimsRouter::render().
  • LIMS\Platform\Access\LimsAccess — Wires labmin/access-control (AccessSync & AccessResolver) to features/sub_features, users.roleID, legacy grants, and optional Redis cache.
  • LIMS\Platform\Flags\LimsFlags — Wires labmin/feature-flags (FeatureFlags) to users.roleID, access_roles, and optional Redis cache. Static ensureSchema() runs in LimsRouter::render().
  • LIMS\Platform\UI\AddEditView\AddEditView & LIMS\Platform\UI\Select — Server-rendered PHP form helpers for non-Fusion legacy pages only.

Labmin LIMS Module Developer Documentation