PHPackages                             pckg/htmlbuilder - 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. pckg/htmlbuilder

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

pckg/htmlbuilder
================

Build advanced forms in php with datasources, decorators, handlers and validators

45.4k[1 issues](https://github.com/pckg/htmlbuilder/issues)[1 PRs](https://github.com/pckg/htmlbuilder/pulls)PHP

Since Apr 15Pushed 1y ago1 watchersCompare

[ Source](https://github.com/pckg/htmlbuilder)[ Packagist](https://packagist.org/packages/pckg/htmlbuilder)[ RSS](/packages/pckg-htmlbuilder/feed)WikiDiscussions next-8.0 Synced 1mo ago

READMEChangelogDependenciesVersions (3)Used By (0)

About HtmlBuilder
=================

[](#about-htmlbuilder)

[![Build status](https://github.com/pckg/htmlbuilder/workflows/Pckg%20Htmlbuilder%20CI/badge.svg)](https://github.com/pckg/htmlbuilder/workflows/Pckg%20Htmlbuilder%20CI/badge.svg)Build advanced forms in PHP with datasources, decorators, handlers and validators.

Functionalities
===============

[](#functionalities)

Htmlbuilder is built with simplicity in mind. Use validators to automatically validate data on client and server side and notify user about errors. Datasources allows you to simply bind different kind of data to form, fieldset, field or other element and let them do magic - they just know how to transfer values between datasource, PHP, HTML and JS. With handlers you can quickly add functionalities to elements and organize your logic. Decorators are mostly used for designing fields. If you use some kind of Twitter Bootstrap themes in your project then you'll be able to write decorator logic only once and apply it on all your forms. Or you can simply use our precoded Bootstrap form and let it "do it's thing". And finally, plugins. We prepared plugins for TWIG and Blade templating system so you can code core of your form in PHP and then add classes, reorder elements or design fields.

Form
----

[](#form)

### Form

[](#form-1)

```
use Htmlbuilder\Form;

class EmptyForm extends Form {

    public function run() {
        $this->addText('name');
    }

}

```

... produces ...

```

```

### Bootstrap

[](#bootstrap)

```
use Htmlbuilder\Form\Bootstrap as Form;

class EmptyForm extends Form {

    public function run() {
        $this->addText('name')->setLabel('Name');
    }

}

```

... produces ...

```

            Name

```

Validators
----------

[](#validators)

All fields have already added validators (example, Htmlbuilder\\Element\\Input\\Datetime has Htmlbuilder\\Validator\\Datetime validator).

### Required

[](#required)

```
$field->require();

```

### Email

[](#email)

```
$field->requireEmail();

```

### Text

[](#text)

```
$field->requireMin();
$field->requireMax();
$field->requireBetween();

```

### Number

[](#number)

```
$field->requireInteger();
$field->requirePositive();
$field->requireNegative();
$field->requireEmpty();
$field->requireFloat();
$field->requireCurrency();
$field->requireMin();
$field->requireMax();
$field->requireBetween();

```

### Date, Time and Datetime

[](#date-time-and-datetime)

```
$field->requireDate();
$field->requireTime();
$field->requireDatetime();

$field->requireMin();
$field->requireMax();
$field->requireBetween();
$field->requireFuture();
$field->requirePast();

```

### Regex

[](#regex)

```
$field->requireRegex();

```

Datasources
-----------

[](#datasources)

### Array

[](#array)

```
$element->fillWithArray(['name' => 'Bill Clinton']);

```

### Object

[](#object)

Object datasource automatically fills element's value with existent and accessable getters, setters and public properties.

```
$element->fillWithObject($user);

```

### Record (LFW/Database/Record)

[](#record-lfwdatabaserecord)

Does same as Object datasource, except it also provides some additional functionality.

```
$element->fillWithRecord($rUser);

```

### Post / Request / Session / Cookie

[](#post--request--session--cookie)

Similar to other datasources they provide automatic storing and fetching data from request variables.

```
$element->fillWithPost($rUser);

```

Handlers
--------

[](#handlers)

Handlers are basically element's decorators, so you can simply add functionality to speciffic or groups of elements by creating new one and adding it to the list of element's handlers. This is how we handled addText(), addNumber() and getClosest().

### Basic

[](#basic)

### Query

[](#query)

Decorators
----------

[](#decorators)

This really are decorators because they're executed in process of HTML generation. Basic elements are printed only with element name (example: div) and attributes (example: class="bordered"). With decorators can you, for example, bind form and it's values to AngularJS model, enable onSuccess and onError Javascript handlers. Or wrap input in Twitter Bootstrap HTML, enable Crsf protection and advanced Javascript validation.

### AngularJS

[](#angularjs)

### Bootstrap

[](#bootstrap-1)

### Csrf

[](#csrf)

Plugins
-------

[](#plugins)

Every web developer knows that you cannot build form by using only PHP. You simply cannot put every design change in HTML to decorator, so we solved this problem by creating macros, snippets or whatever you call them for changing form in templating engines. From now on you will be able to put all logic in PHP and change field position in HTML, some attribute or add button directly in template engine.

### TWIG

[](#twig)

```
{{ form.open }}
Some HTML ...
{{ form.field.name }}
Some HTML ...
{{ form.fieldset.index }}
Some HTML ...
{{ form.buttonset }}
Some HTML ...
{{ form.close }}

```

### Blade

[](#blade)

Notes
=====

[](#notes)

Please note that Htmlbuilder is not (yet) prepared for production use. We still need to write some functional and unit tests, prepare examples, optimize and document code. =)

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance23

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity29

Early-stage or recently created project

 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/b94b3bcec679374372be12374d132c7852fcabf1cc6339763d81a63e384b74f3?d=identicon)[schtr4jh](/maintainers/schtr4jh)

---

Top Contributors

[![schtr4jh](https://avatars.githubusercontent.com/u/385801?v=4)](https://github.com/schtr4jh "schtr4jh (203 commits)")

### Embed Badge

![Health badge](/badges/pckg-htmlbuilder/health.svg)

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

###  Alternatives

[mkusher/padawan

Smart php completion server

2547.2k](/packages/mkusher-padawan)[aliqasemzadeh/livewire-bootstrap-modal

Dynamic Laravel Livewire 3 Bootstrap modals.

4620.5k](/packages/aliqasemzadeh-livewire-bootstrap-modal)[ichhabrecht/core-upgrader

Run upgrade wizards for multiple TYPO3 versions at once

2732.0k](/packages/ichhabrecht-core-upgrader)[brightnucleus/geolite2-country

Composer-packaged version of the free MaxMind GeoLite2 Country database.

2318.0k](/packages/brightnucleus-geolite2-country)

PHPackages © 2026

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