Skip to content

Getting Started with ui

Requires PHP ^8.2. Install via Composer:

bash
composer require middag-io/ui

Compose a form layout from immutable value objects — the result serializes to a JSON contract a renderer consumes:

php
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

ConsumerHow
middag-io/frameworkMaps 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

MIDDAG © 2015-2026