PHPackages                             rkr/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. rkr/forms

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

rkr/forms
=========

13PHPCI failing

Since Mar 22Pushed 5y ago2 watchersCompare

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

READMEChangelogDependenciesVersions (3)Used By (0)

php-forms
=========

[](#php-forms)

[![Build Status](https://camo.githubusercontent.com/4ecfd16df90e3bf2394eb8b0d215522e9ff22a1a49b79a7157da7a799d2a7a73/68747470733a2f2f7472617669732d63692e6f72672f726b72782f7068702d666f726d732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/rkrx/php-forms)

Introduction
------------

[](#introduction)

There are many php based form classes out there. I have used many of them and visited even more before I decided to develop my own approach. So this project is based on some experience and covers mostly my own needs.

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

[](#installation)

```
composer require rkr/forms
```

Example
-------

[](#example)

### First Render

[](#first-render)

We first have to create a structure that will later represent our form, and subsequently convert the entered data and perform the validation:

```
use Forms\Form;

$section = new Form\Section('Section', ['xyz' => 123],
    new Form\Checkbox(['data', 'active'], 'Active'),
    new Form\Input(['data', 'name'], 'Name', ['required' => true, 'minlenght' => 5, 'maxlength' => 64]),
    new Form\Email(['data', 'email'], 'Email')
);
```

Then we can create a data structure from the structure:

```
$structure = $section->render([], false);
print_r(json_encode($structure, JSON_PRETTY_PRINT));
```

```
{
    "type": "section",
    "elements": [{
        "name": ["data", "active"],
        "title": "Active",
        "value": null,
        "messages": [],
        "attributes": [],
        "type": "checkbox"
    }, {
        "name": ["data", "name"],
        "title": "Name",
        "value": null,
        "messages": [],
        "attributes": {
            "required": true,
            "minlenght": 5,
            "maxlength": 64
        },
        "type": "input"
    }, {
        "name": ["data", "email"],
        "title": "Email",
        "value": null,
        "messages": [],
        "attributes": [
            "required": true
        ],
        "type": "email"
    }],
    "attributes": {"xyz": 123},
    "title": "Section"
}

```

If we already have data, then this data is included in the generated data structure. That's it for the first step, actually. The output can now be made with any template engine. I mainly use PHP and Twig in my projects, but any template engine can be used.

### Conversion

[](#conversion)

Instructions follow...

### Validation and second Render

[](#validation-and-second-render)

Instructions follow...

Zen of Forms
------------

[](#zen-of-forms)

- It should be easy to reason about data
- Building forms should be as intuitive as possible
- Forms should be built using declarative data and user defined templates
- Ability to replace existing components and build your own
- I18N and L10N is crucial
- Need as few external dependencies as possible
- PHP-Code must be statically clean

TODO
----

[](#todo)

- Tested base components
- Handling for I18N and L10N
- Usage example
- Every component must not change internal state by design by calling `convert`, `validate` or `render`, after the component was initialized.

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity44

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/7f83d7e57a4bf3f1309680dbfbbf2d022f0ee6dae64a4b3bdfbed1226f2f6bef?d=identicon)[rkr](/maintainers/rkr)

---

Top Contributors

[![rkrx](https://avatars.githubusercontent.com/u/5672982?v=4)](https://github.com/rkrx "rkrx (22 commits)")

### Embed Badge

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

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

###  Alternatives

[kevinlebrun/slug.php

Slug helpers

4451.4k1](/packages/kevinlebrun-slugphp)

PHPackages © 2026

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