Getting Started with ui
Requires PHP ^8.3 (8.3, 8.4 and 8.5 are supported; see Platform). Install via Composer:
composer require middag-io/uiCompose a form layout from immutable value objects — the result serializes to a JSON contract a renderer consumes:
use Middag\Ui\Block\Section;
use Middag\Ui\Form\Group;
$section = Section::of('personal')
->label('Personal details')
->fields(
$nameField,
$emailField,
Group::of('phone')->fields($countryField, $numberField),
);That’s the whole idea: you never write markup, you compose value objects — the same contract renders standalone, inside a Moodle plugin, or inside WordPress, by swapping the renderer downstream.
Where it’s consumed
| Consumer | How |
|---|---|
middag-io/framework |
Maps the contracts to its Inertia renderer and form pipeline. |
| Host adapters (Moodle, WordPress) | Render the contract through the host’s UI, via the framework. |
@middag-io/react (NPM) |
Consumes the emitted JSON page contract on the client. |
Next
- Architecture — the PageContract system, the composition levels, the concern-first layout, and why nothing here renders.
- Page Composition Contract — the verified L1-L3 PHP entry points and the
PageContract/BlockDescriptorshape.