PHPackages                             mathsgod/formkit-php - 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. mathsgod/formkit-php

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

mathsgod/formkit-php
====================

1.0.7(2y ago)035MITPHP

Since Aug 17Pushed 2y ago1 watchersCompare

[ Source](https://github.com/mathsgod/formkit-php)[ Packagist](https://packagist.org/packages/mathsgod/formkit-php)[ RSS](/packages/mathsgod-formkit-php/feed)WikiDiscussions main Synced today

READMEChangelog (8)DependenciesVersions (9)Used By (0)

formkit-php
===========

[](#formkit-php)

A PHP library for generating [FormKit Schema](https://formkit.com/essentials/schema) from PHP classes.

Installation
------------

[](#installation)

Install via composer:

```
composer require mathsgod/formkit-php
```

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

```
$schema = new FormKit\Schema();
$schema->appendHTML("");
echo json_encode($schema, JSON_PRETTY_PRINT);
```

output:

```
[
    {
        "$formkit": "text",
        "label": "hello"
    }
]
```

### Simple element

[](#simple-element)

```
$schema = new FormKit\Schema();
$schema->appendElement("div")->appendElement("span")->appendHTML("hello");
echo json_encode($schema, JSON_PRETTY_PRINT);
```

output:

```
[
    {
        "$el": "div",
        "children": [
            {
                "$el": "span",
                "children": [
                    "hello"
                ]
            }
        ]
    }
]
```

### Component

[](#component)

```
$schema = new FormKit\Schema();
$card=$schema->appendComponent("q-card");
$card->setAttribute("flat","");

echo json_encode($schema, JSON_PRETTY_PRINT);

```

output:

```
[
    {
        "$cmp": "q-card",
        "props": {
            "flat": true
        }
    }
]
```

### Registering custom Vue components

[](#registering-custom-vue-components)

```
$schema = new FormKit\Schema();
$schema->registerClass("q-card", FormKit\Component::class);
$schema->appendHTML("Hello");

echo json_encode($schema, JSON_PRETTY_PRINT);
```

output:

```
[
    {
        "$cmp": "q-card",
        "props": {
            "flat": true
        },
        "children": [
            "Hello"
        ]
    }
]
```

### Registering custom FormKit input components

[](#registering-custom-formkit-input-components)

```
$schema = new FormKit\Schema();
$schema->registerInputClass("my-input", FormKit\FormKitInputs::class);
$schema->appendHTML("");
echo json_encode($schema, JSON_PRETTY_PRINT);
```

output:

```
[
    {
        "$formkit": "my-input",
        "label": "My custom input"
    }
]
```

### Custom component class

[](#custom-component-class)

```
class QBtn extends FormKit\Component
{

    public function setLabel($label)
    {
        $this->setAttribute("label", $label);
    }
}

$schema = new FormKit\Schema();
$schema->registerClass("q-btn", QBtn::class);
$node=$schema->appendHTML("")[0]; //$node=$schema->appendComponent("q-btn");

//change label
$node->setLabel("World");

echo json_encode($schema, JSON_PRETTY_PRINT);
```

output:

```
[
    {
        "$cmp": "q-btn",
        "props": {
            "label": "World"
        }
    }
]
```

### Append child nodes

[](#append-child-nodes)

```
$schema = new FormKit\Schema();
$e = $schema->appendHTML("")[0];
$e->append($schema->createElement("div", "hello"));
echo json_encode($schema, JSON_PRETTY_PRINT);
```

output:

```
[
    {
        "$el": "div",
        "children": [
            {
                "$el": "div",
                "children": [
                    "hello"
                ]
            }
        ]
    }
]
```

### Append child nodes from HTML

[](#append-child-nodes-from-html)

```
$schema = new FormKit\Schema();
$e = $schema->appendHTML("")[0];
$e->appendHTML("hello");
echo json_encode($schema, JSON_PRETTY_PRINT);
```

output:

```
[
    {
        "$el": "div",
        "children": [
            {
                "$el": "div",
                "children": [
                    "hello"
                ]
            }
        ]
    }
]
```

### Loops

[](#loops)

```
$group = $schema->appendHTML("")[0];
$group->setAttribute(":value", json_encode([
    "cities" => ["Hong Kong", "Taiwan", "China"]
]));

$div = $group->appendElement("div");

$div->for(["item", "key", '$value.cities']);

$div->appendHTML('$item');

echo json_encode($schema, JSON_PRETTY_PRINT);
```

output:

```
[
    {
        "$formkit": "group",
        "label": "Group",
        "value": {
            "cities": [
                "Hong Kong",
                "Taiwan",
                "China"
            ]
        },
        "children": [
            {
                "$el": "div",
                "children": [
                    "$item"
                ],
                "for": [
                    "item",
                    "key",
                    "$value.cities"
                ]
            }
        ]
    }
]
```

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~0 days

Total

8

Last Release

1050d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/18732337?v=4)[Raymond](/maintainers/mathsgod)[@mathsgod](https://github.com/mathsgod)

---

Top Contributors

[![mathsgod](https://avatars.githubusercontent.com/u/18732337?v=4)](https://github.com/mathsgod "mathsgod (29 commits)")

---

Tags

formkitphp

### Embed Badge

![Health badge](/badges/mathsgod-formkit-php/health.svg)

```
[![Health](https://phpackages.com/badges/mathsgod-formkit-php/health.svg)](https://phpackages.com/packages/mathsgod-formkit-php)
```

PHPackages © 2026

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