Skip to content

labmin/fusion & @labmin/fusion-angular ​

Server-side PHP renderer (labmin/fusion ^0.4) and Angular client runtime (@labmin/fusion-angular ^0.6.2) that drive shadow-root Angular pages with zero full-page reloads.

PHP API (Labmin\Fusion\Fusion) ​

php
use Labmin\Fusion\Fusion;
use Labmin\Fusion\FusionResponse;
MethodSignatureDescription
Fusion::configure()configure(array $config): voidConfigures 'development' (true for Vite dev server, false for dist/.vite/manifest.json), 'vite_dev_server', 'build_url', 'manifest_path', 'modules_path', 'submodules_dir', 'views_dir'.
Fusion::render()render(string $component, array $props = [], int $status = 200, array $headers = []): FusionResponseReturns a Fusion page response. A relative path (e.g. 'OrderList/OrderList.component.ts') resolves automatically against UI/Views/ of the caller's nearest module or submodule; paths starting with / are used verbatim. Props accept plain values, JsonSerializable DTOs, closures, or Fusion::defer().
Fusion::defer()defer(Closure $callback, string $group = 'default'): DeferredPropDefers an expensive prop so the page renders first and fetches deferred groups automatically after mount.
Fusion::isAppRequest()isAppRequest(): boolReturns true when HTTP_X_APP_REQUEST === 'true'.
Fusion::assetTags()assetTags(string $entry): stringOutputs Vite dev client tags or hashed production <script> + <link rel="modulepreload"> tags from manifest.json.
Fusion::assetVersion()assetVersion(): string'dev' locally, or MD5 hash of manifest.json in production (forces a clean browser reload after deployments).

Angular Client API (@labmin/fusion-angular) ​

App mounting (admin/app.ts) ​

ts
import { mountFusionApp } from "@labmin/fusion-angular";
import css from "./app.css?inline";
import { App } from "./app.component";

mountFusionApp(App, rootElement, {
  css,
  views: import.meta.glob("/admin/Modules/**/UI/Views/**/*.component.ts"),
  // viewTransitions: false, // optional: disables View Transitions API cross-fade
});

Place <fusion-router /> (FusionRouter) in the root component (admin/app.component.ts).

ExportSignature / UsageNotes
urlurl(action?, { feature?, query? })Builds ?feature=...&action=...&... matching PHP's Router::url(). Omits null/undefined query keys. Pass feature: null for the default controller; omit feature to keep the current controller.
FusionLink<a fusionLink [href]="url(...)">Intercepts plain clicks on ? URLs and routes through navigate(). Leaves Ctrl/Cmd-click, middle-click, external paths, target, and download links to the browser.
navigatenavigate(href, options?): Promise<boolean>Fetches and mounts the target Fusion page without reload. Resolves true if a page rendered; on HttpException, keeps the current page and populates router.error().
getActiongetAction(action, query?, options?)GET ?action=... expecting Fusion::render(...).
postActionpostAction(action, data?, options?)POST ?action=... (form fields) expecting Fusion::render(...).
ajaxActionajaxAction<T>(action, data?, { feature? })POST ?action=... sending JSON body and returning parsed JSON. Throws FusionRequestError on non-2xx. (Note: skips LimsRouter's $_POST normalization — prefer postForm() for forms.)
fusionFormIntercept<form fusionFormIntercept [action]="url('create')">Intercepts form submission expecting Fusion::render(...). Maps 422 errors into router.errors(); emits fusionSubmitted on success.
FusionRequestErrorerror.status, error.bodyError class thrown by ajaxAction() and postForm() helpers on non-2xx responses.

Reactive router state ​

ts
import { router, isDeferredLoading } from "@labmin/fusion-angular";

router.component();       // Signal: current view component path
router.props();           // Signal: current page props
router.url();             // Signal: current URL
router.errors();          // Signal: validation errors map from fusionFormIntercept
router.error();           // Signal: error message from failed navigate()/getAction()
router.loading();         // Signal: navigation in progress
router.deferredLoading(); // Signal: deferred prop groups currently loading

isDeferredLoading("workItems"); // boolean helper for Fusion::defer() props

Labmin LIMS Module Developer Documentation