Skip to content

ui — Getting Started

Updated View as Markdown

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/ui

Compose 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/BlockDescriptor shape.
Navigation

Type to search…

↑↓ navigate↵ selectEsc close