PHPackages                             misantron/bricks - 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. misantron/bricks

ActiveLibrary

misantron/bricks
================

Flexible form builder with data validation and pre processing

v1.0.0(8y ago)181MITPHPPHP &gt;=7.0

Since Jan 28Pushed 7y ago1 watchersCompare

[ Source](https://github.com/misantron/bricks)[ Packagist](https://packagist.org/packages/misantron/bricks)[ Docs](https://github.com/misantron/bricks)[ RSS](/packages/misantron-bricks/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (5)Versions (4)Used By (0)

Bricks
======

[](#bricks)

[![Build Status](https://camo.githubusercontent.com/01dffaba13017f7117a1b1acf319daeebf099a8d01230d72a05b01827ab1b9fd/687474703a2f2f696d672e736869656c64732e696f2f7472617669732f6d6973616e74726f6e2f627269636b732e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/misantron/bricks)[![Code Coverage](https://camo.githubusercontent.com/08006d8f721c8a847728d7afd87f2581352a461b0b88c6609d634496cf60282d/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f6d6973616e74726f6e2f627269636b732e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/misantron/bricks)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/039acbedaf3ffc9d83211e22ca01d58d6471dc4e014ba60df7418473a50cd66e/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6d6973616e74726f6e2f627269636b732e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/misantron/bricks)[![Packagist](https://camo.githubusercontent.com/6a95d6d0fcba1c7062c85d3e15f7b47ffd1383e778d08409a01f3441fba17ffc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d6973616e74726f6e2f627269636b732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/misantron/bricks)[![PHP 7 Support](https://camo.githubusercontent.com/bac671a23af8f0a75eb4de8eaf34c5e1a1f70cb40223175a0d6810e80232fdd4/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f504850253230372d737570706f727465642d626c75652e7376673f7374796c653d666c61742d737175617265)](https://github.com/misantron/bricks)

Flexible form builder with data validation and pre processing.

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

[](#installation)

Run [Composer](https://getcomposer.org) from command line:

```
composer require misantron/bricks

```

Or add dependency to `composer.json`:

```
{
    "require": {
        "misantron/bricks": "dev-master"
    }
}

```

Usage
-----

[](#usage)

Create a new form by inheriting `\Bricks\AbstractForm`. Abstract method `fields()` must be implemented with configuration array:

```
class SomeForm extends \Bricks\AbstractForm
{
    protected funtion fields(): array
    {
        return [
            'foo' => [
                'type' => 'string', // using for data type cast
                'validators' => [
                    'required' => true,
                    'lengthMax' => 64,
                ],
            ],
            'bar' => [
                'type' => 'integer', // using for data type cast
                'validators' => [
                    'required' => true,
                    'in' => function () {
                        return [1, 2];
                    }
                ],
                'cleanup' => true, // flag that field will be deleted from getData() method call response
            ],
        ];
    }
}
```

Form workflow inside application controller/service/etc.:

```
$request = Request::fromGlobals(); // must implements \Psr\Http\Message\RequestInterface

$default = [
    'foo' => 'test',
];

$form = \SomeForm::create()
    ->setData($default) // allows to pass an initial data before handling the request
    ->handleRequest($request) // get data from the request and data processing
    ->validate(); // data validation

$data = $form->getData(); // extracting processed and validated data from form
```

Built-in field types
--------------------

[](#built-in-field-types)

`string`, `integer`, `float`, `boolean`, `array` (contains elements of different types), `dateTime` (transform datetime string or timestamp to [Carbon](https://github.com/briannesbitt/Carbon) object) , `intArray`, `strArray`, `floatArray`

Custom user type can be easily added:

```
class MyTransducer extends \Bricks\Data\Transducer
{
    private funtion myType($value)
    {
        // your custom logic here
    }
}
```

Built-in field validation rules
-------------------------------

[](#built-in-field-validation-rules)

See [Valitron](https://github.com/vlucas/valitron) documentation. If form data is not valid - `\Bricks\Exception\ValidationException` will be thrown:

```
try {
    $form->validate();
} catch (\Bricks\Exception\ValidationException $e) {
    var_dump($e->getData()); // getting fields error data
}
```

###  Health Score

26

—

LowBetter than 46% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity60

Established project with proven stability

 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 ~115 days

Total

3

Last Release

2744d ago

Major Versions

v1.0.0 → v2.x-dev2018-09-15

### Community

Maintainers

![](https://www.gravatar.com/avatar/bd770c15388efa80552143bb41ecd34e433ef065a8682a5e62bc39002620fc50?d=identicon)[misantron](/maintainers/misantron)

---

Top Contributors

[![misantron](https://avatars.githubusercontent.com/u/9839955?v=4)](https://github.com/misantron "misantron (33 commits)")

---

Tags

formform-builderform-validationframework-agnosticphpphpbuilderform

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/misantron-bricks/health.svg)

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

###  Alternatives

[gmostafa/php-graphql-client

GraphQL client and query builder.

3167.3M22](/packages/gmostafa-php-graphql-client)[bacula-web/bacula-web

The open source web based reporting and monitoring tool for Bacula

1537.5k](/packages/bacula-web-bacula-web)

PHPackages © 2026

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