PHPackages                             kanopi/schema-forms - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. kanopi/schema-forms

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

kanopi/schema-forms
===================

Creates form definitions from JSON Schema property definitions and display configuration.

v2.5.2(9mo ago)0166[2 PRs](https://github.com/kanopi/schema-forms-php/pulls)GPL-2.0-or-laterPHPPHP &gt;=7.4CI failing

Since Jul 26Pushed 3mo agoCompare

[ Source](https://github.com/kanopi/schema-forms-php)[ Packagist](https://packagist.org/packages/kanopi/schema-forms)[ RSS](/packages/kanopi-schema-forms/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (15)Versions (35)Used By (0)

Schema Forms
============

[](#schema-forms)

Schema forms is a project that aims to generate form structures for the different PHP frameworks based on the data definitions in JSON Schema.

Frameworks supported:

- Drupal.

Usage
=====

[](#usage)

Given the following JSON Schema defining the different properties of a user object.

```
{
  "title": "A registration form",
  "description": "A simple form example.",
  "type": "object",
  "required": [
    "firstName",
    "lastName"
  ],
  "properties": {
    "firstName": {
      "type": "string",
      "title": "First name",
      "default": "Chuck"
    },
    "lastName": {
      "type": "string",
      "title": "Last name"
    },
    "age": {
      "type": "integer",
      "title": "Age",
      "description": "(earthian year)"
    },
    "bio": {
      "type": "string",
      "title": "Bio"
    },
    "password": {
      "type": "string",
      "title": "Password",
      "minLength": 3,
      "description": "The key to get in."
    },
    "telephone": {
      "type": "string",
      "title": "Telephone",
      "minLength": 10
    }
  }
```

And the following UI JSON Schema refining the form generation process:

```
{
  "firstName": {
    "ui:autofocus": true,
    "ui:emptyValue": ""
  },
  "age": {
    "ui:widget": "updown",
    "ui:title": "Age of person"
  },
  "bio": {
    "ui:widget": "textarea"
  },
  "password": {
    "ui:widget": "password",
    "ui:help": "Hint: Make it strong!"
  },
  "date": {
    "ui:widget": "alt-datetime"
  },
  "telephone": {
    "ui:options": {
      "inputType": "tel"
    }
  }
}
```

Execute this PHP code:

```
use SchemaForms\Drupal\FormGeneratorDrupal;
$generator = new FormGeneratorDrupal();
$context = new Context(['ui_hints => $ui_schema_data]);
$actual_form = $generator->transform($schema_data, $context);
// It generates the following Drupal Form API form:
[
  'firstName' => [
    '#type' => 'textfield',
    '#title' => 'First name',
    '#required' => TRUE,
  ],
  'lastName' => [
    '#type' => 'textfield',
    '#title' => 'Last name',
    '#required' => TRUE,
  ],
  'age' => [
    '#type' => 'number',
    '#title' => 'Age of person',
    '#description' => '(earthian year)'
  ],
  'bio' => [
    '#type' => 'textarea',
    '#title' => 'Bio',
  ],
  'password' => [
    '#type' => 'password',
    '#title' => 'Password',
    '#description' => 'Hint: Make it strong!'
  ],
  'telephone' => [
    '#type' => 'telephone',
    '#title' => 'Telephone',
  ],
];
```

### UI Schema Data

[](#ui-schema-data)

Based on the shape of the data described by the JSON Schema, this library can generate a form. However, there are multiple ways to generate a form for the same shape of data. The UI schema data allows you to control the form elements and inputs that will collect the data in the appropriate way.

Supported UI controls are:

- `$ui_form_data['ui:title']`

    Controls the label associated to the input element. Defaults to the element's `title` property in the JSON Schema.
- `$ui_form_data['ui:help']`

    Adds a hint to the input element. Defaults to the element's `description` property in the JSON Schema.
- `$ui_form_data['ui:placeholder']`

    Adds a placeholder text to the input.
- `$ui_form_data['ui:widget']`

    Lets you use al alternative input element. For instance, it lets you use `` instead of ``, or use ``, among others.
- `$ui_form_data['ui:enabled']`

    If 0 the form element will be rendered as non-interactive.
- `$ui_form_data['ui:visible']`

    If 0 the form element will not be rendered.
- `$ui_form_data['ui:enum']`

    Lets you define how the options for selects and radios are populated. By default, the enum information in the schema defines the options. This might not be enough, or even possible.

    - `$ui_form_data['ui:enum']['labels']['mappings']`

    An object defining the label for each key. Ex: `{"uuid1": "Super duper product"}`.

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance69

Regular maintenance activity

Popularity10

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 92.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~110 days

Recently: every ~269 days

Total

21

Last Release

285d ago

Major Versions

0.1.2 → v1.0.02022-07-19

v1.0.2 → v2.0.02022-07-20

PHP version history (3 changes)0.1.0PHP &gt;=7

v1.0.0PHP &gt;=8.1

v2.3.0PHP &gt;=7.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/bf9dca5c46910be861bb00920034637b5a36a1f6277413be6817a50a1ce6fc74?d=identicon)[kanopi\_studios](/maintainers/kanopi_studios)

---

Top Contributors

[![e0ipso](https://avatars.githubusercontent.com/u/1140906?v=4)](https://github.com/e0ipso "e0ipso (49 commits)")[![semantic-release-bot](https://avatars.githubusercontent.com/u/32174276?v=4)](https://github.com/semantic-release-bot "semantic-release-bot (3 commits)")[![kanopicode](https://avatars.githubusercontent.com/u/17830393?v=4)](https://github.com/kanopicode "kanopicode (1 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/kanopi-schema-forms/health.svg)

```
[![Health](https://phpackages.com/badges/kanopi-schema-forms/health.svg)](https://phpackages.com/packages/kanopi-schema-forms)
```

###  Alternatives

[composer/composer

Composer helps you declare, manage and install dependencies of PHP projects. It ensures you have the right stack everywhere.

29.4k187.2M2.6k](/packages/composer-composer)[friendsofphp/php-cs-fixer

A tool to automatically fix PHP code style

13.5k234.7M20.6k](/packages/friendsofphp-php-cs-fixer)[w7corp/easywechat

微信SDK

10.4k761.6k60](/packages/w7corp-easywechat)[ergebnis/composer-normalize

Provides a composer plugin for normalizing composer.json.

1.1k37.3M2.1k](/packages/ergebnis-composer-normalize)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

728272.9k20](/packages/civicrm-civicrm-core)[getdkan/dkan

DKAN Open Data Catalog

385135.4k2](/packages/getdkan-dkan)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
