Appearance
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
| Method | Description |
|---|---|
render(): void | Ensures 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(): bool | Returns true when HTTP_X_APP_REQUEST is non-empty or $_GET['raw'] === '1'. |
LimsRouter::appRequestFile(): ?string | Called 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(): ?string | Resolves /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(generateandeditSeedsenabled only whenSTATE === 'LOCAL')?feature=access—AccessConfigController(module + all submodules)?feature=flags—FlagConfigController(module + all submodules)
CurrentUser
Injected automatically into controllers and services by LimsRouter.
| Member | Type / Signature | Description |
|---|---|---|
CurrentUser::fromSession() | self | Builds from $_SESSION['loggedin']. |
$id | int | users.id (0 if not logged in). |
$name | string | Logged-in username. |
$personnelId | ?int | Linked personnel.id, or null. |
isLoggedIn() | bool | Whether a valid user session exists. |
isMaster() | bool | Whether the user has Master access. |
can(string $module, string $action) | bool | Checks an access_config.php action via AccessControl::canDo(). |
hasFlag(string $module, string $flag) | bool | Checks a flag_config.php flag via LimsFlags. |
Repository
Abstract base class for module repositories (public function __construct(protected readonly DatabaseManager $db)).
| Protected method | Return | Purpose |
|---|---|---|
one(string $class, string $sql, array $params = []) | ?object | Hydrates 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 = []) | mixed | First column of the first row, or null. |
run(string $sql, array $params = []) | int | Runs INSERT/UPDATE/DELETE; returns insert ID or affected rows. |
insert(object|string $schema, ?array $data = null) | int | Validated MaterializeMySql::insert(). Returns generated ID. |
update(object|string $schema, ?array $data = null) | int | Validated MaterializeMySql::update(). Requires primary key(s). |
self::placeholders(array $values) | string | Builds "?, ?, ?" for SQL IN (...) lists ("NULL" when empty). |
self::hydrate(array $row, string $class) | object | Maps SQL columns (and #[Column(column: ...)] aliases) onto $class, cleaning '' and '0000-00-00' to null for nullable properties. |
Platform Wrappers
LIMS\Platform\FileStorage\LimsFileStorage— ExtendsLabmin\FileStorage\Services\FileStorage, wired automatically toDatabaseManager,.env FILE_STORAGE_ROOT, andCurrentUser. StaticensureSchema()runs inLimsRouter::render().LIMS\Platform\Access\LimsAccess— Wireslabmin/access-control(AccessSync&AccessResolver) tofeatures/sub_features,users.roleID, legacy grants, and optional Redis cache.LIMS\Platform\Flags\LimsFlags— Wireslabmin/feature-flags(FeatureFlags) tousers.roleID,access_roles, and optional Redis cache. StaticensureSchema()runs inLimsRouter::render().LIMS\Platform\UI\AddEditView\AddEditView&LIMS\Platform\UI\Select— Server-rendered PHP form helpers for non-Fusion legacy pages only.