rocket-php / rocket-ui
Installs: 21
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/rocket-php/rocket-ui
Requires
- ext-dom: *
- friendsofphp/php-cs-fixer: ^3.65
- phpunit/phpunit: ^11.5
- rocket-php/rocket-gate: *
- rocket-php/rocket-rule: *
- spatie/phpunit-watcher: ^1.24
Requires (Dev)
- ext-libxml: *
- dev-main
- v1.0.57
- v1.0.56
- v1.0.55
- v1.0.54
- v1.0.53
- v1.0.52
- v1.0.51
- v1.0.50
- v1.0.49
- v1.0.48
- v1.0.47
- v1.0.46
- v1.0.45
- v1.0.44
- v1.0.43
- v1.0.42
- v1.0.41
- v1.0.40
- v1.0.39
- v1.0.38
- v1.0.37
- v1.0.36
- v1.0.35
- v1.0.34
- v1.0.33
- v1.0.32
- v1.0.31
- v1.0.30
- v1.0.29
- v1.0.28
- v1.0.27
- v1.0.26
- v1.0.25
- v1.0.24
- v1.0.23
- v1.0.22
- v1.0.21
- v1.0.20
- v1.0.19
- v1.0.18
- v1.0.17
- v1.0.16
- v1.0.15
- v1.0.14
- v1.0.13
- v1.0.12
- v1.0.11
- v1.0.10
- v1.0.9
- v1.0.8
- v1.0.7
- v1.0.6
- v1.0.5
- v1.0.4
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
- dev-codex/fix-input-date-value-return-gvdhli
- dev-codex/fix-input-date-value-return
This package is auto-updated.
Last update: 2025-10-23 01:54:50 UTC
README
RocketUI
RocketUI turns XML view definitions into ready-to-render JSON responses. It powers dynamic forms and grids by hydrating layouts with values sourced from PHP domain objects and can also export React JSON Schema Form (RJSF) compatible structures.
Features
- Parse XML layouts (validated with the bundled XSDs) into structured form and grid definitions.
- Hydrate field values from PHP objects via public properties or getters, including nested dot-notation lookups.
- Generate RJSF
schema
,uiSchema
, andformData
payloads from the native layout JSON. - Support UI primitives such as containers, tabs, inputs, selects, status chips, file uploads, toasts, and actions.
- Provide a small utility layer for conditional rendering, value parsing, and reusable layout components.
Requirements
- PHP 8.2 or higher (required by PHPUnit 11).
- The
ext-dom
andext-libxml
extensions. - Composer for dependency management.
Installation
composer require rocket-php/rocket-ui
If you are working within this repository, install the dev dependencies first:
composer install
Defining a Form
Layouts are described in XML and validated against src/Views/Form/XSD/schema.xsd
. A minimal example looks like:
<RocketForm xmlns="http://rocket.com/rf-schema"> <metadata> <title>Customer Profile</title> <description>Primary contact information</description> <version>1.0</version> </metadata> <layout type="modal"> <container id="main" label="Details" direction="column"> <input name="name" type="text" label="Name" required="true" /> <input name="email" type="email" label="Email" /> <status name="status" label="Status" /> </container> </layout> <actions> <button type="primary" name="submit" label="Save" /> </actions> </RocketForm>
See tests/data/form.xml
and tests/data/grid.xml
for more complete samples and schema coverage.
Usage
use RocketPhp\RocketUI\UIEngine; use RocketPhp\RocketUI\Views\Form\Form; $form = new Form(__DIR__ . '/form.xml'); $data = new class () { public string $name = 'Ada Lovelace'; public function getEmail(): string { return 'ada@example.com'; } public function getStatus(): string { return 'active'; } }; $engine = new UIEngine(); // Native form layout (metadata, layout blocks, actions) $jsonLayout = $engine->buildForm($form, $data); // React JSON Schema Form payloads $rjsfPayload = $engine->buildRJSFSchema($form, $data);
The buildForm
method walks the layout, resolves values (including nested properties like address.street
), and returns a JSON string. buildRJSFSchema
adapts that response for RJSF consumers, producing the familiar schema
, uiSchema
, and formData
arrays.
Grids follow the same pattern via RocketPhp\RocketUI\Views\Grid\Grid
definitions and UIEngine::buildGrid()
.
Running Tests
Execute the full suite with:
./vendor/bin/phpunit
To continuously run tests while developing, the project ships with spatie/phpunit-watcher
:
./vendor/bin/phpunit-watcher watch
The provided tests (tests/formTest.php
) also demonstrate real-world usage, including XML validation, value hydration, and RJSF conversion.
Project Structure
src/UIEngine.php
– entry point for converting form and grid definitions into JSON payloads.src/Views/Form
– XML parsing, layout components, actions, and helper services for forms.src/Views/Grid
– grid layout parsing and rendering helpers.src/Adapter/RjsfSchemaBuilder.php
– converts native form layouts into RJSF structures.tests/
– PHPUnit suites plus fixture XML/JSON data.
License
RocketUI is open-sourced software licensed under the MIT license.