Transport-agnostic PHP contract builders for contract-driven UI. Describe a page once — its regions, forms, tables, blocks, navigation and actions — as an immutable value object, then let any host or adapter render it. The library produces a JSON page contract; it never produces HTML.
Describe the page once. Render it anywhere.
The builders carry no transport and no host knowledge: the same contract renders standalone, inside a Moodle plugin, or inside WordPress, by swapping the renderer downstream. See Architecture for how the contract system is built and organized.
Who it is for
- Developers of
middag-io/framework, the host adapters and any renderer that consumes the page contract. - Developers who build pages for a MIDDAG-based product and want them to render on any host.
- Authors of a client, such as
@middag-io/react, that codegens against the published JSON schemas.
Requirements and install
| Item | Value |
|---|---|
| Package | middag-io/ui (middag-php-ui), Apache-2.0 |
| PHP | ^8.3: 8.3, 8.4 and 8.5 |
| Symfony | none: ui depends on no Symfony component |
| Sibling libraries | none: ui is the bottom of the stack and requires no other library |
| Host | none: ui runs with no host |
composer require middag-io/uiThe platform rules behind these values are in Platform and Versioning and compatibility. A first page is built in Getting Started.
Public surface
- Support covers the types tagged
@apionly. Every type insrc/carries exactly one class-level tag,@apior@internal; a type with neither is@internal. An@internaltype may change in any release. - The
@apisurface is the interfaces in each concern’sContract/sub-namespace (suffixInterface), the concern builders and the value objects they produce, and the cross-cutting types underShared/. - The emitted JSON is a second, stronger contract. A PHP rename that leaves the JSON unchanged is not a wire break; a change to the JSON shape is, and follows the same versioning rules (Versioning and compatibility).
API-STABILITY.mdin the repository lists the public surface and the rules for changing it.- The contract reference is on this hub: Page Composition Contract, UI Wire Contract and UI Stack & Design System.
- The JSON schemas the library emits (
schema/page-contract.json,schema/fragment.json) are published artifacts of each release. - In progress: the generated reference of the
@apisurface (Documentation publication) and the PHP-React correspondence map (Documentation publication) are not published yet.
Changelog and releases
- Releases are cut only by release-please from Conventional Commits; there are no manual tags.
CHANGELOG.mdrecords every release.- Releases on GitHub carry the tags, and Packagist serves them to Composer.
Decision records
The records live in the repository, in docs/decisions. This hub explains the design they record; it does not host them.
| Id | Decision |
|---|---|
| UI-001 | UI contracts are a separate zero-dependency package at the bottom of the stack |
| UI-002 | A versioned data contract, published as schema |
| UI-003 | The first-party UI client is React + TypeScript + Inertia + ReUI |
Help
- Questions and bugs: issues of
middag-php-ui. - Security reports:
SECURITY.md. Do not open a public issue for a vulnerability. - Contributions:
CONTRIBUTING.md.
Open source and MIDDAG
middag-io/ui, middag-io/framework, the Moodle and WordPress adapters and middag-io/demo-standalone are open source under Apache-2.0 — the generic plumbing, free, forever. The governed domain infrastructure built on top lives in MIDDAG’s internal (proprietary, not free) libraries, opt-in; product features live in the products. See OSS and internal libraries. This library has zero dependencies and never points at the internal libraries.
Licensing note
Apache-2.0. Support starts at 2.0.0, the first stable release of the library family: from there breaking changes land only in a MAJOR. Earlier releases are pre-stable and unsupported. See Versioning and compatibility.