{"id":22367277,"url":"https://github.com/misantron/bricks","last_synced_at":"2026-07-17T16:33:19.488Z","repository":{"id":57017479,"uuid":"42712852","full_name":"misantron/bricks","owner":"misantron","description":"Flexible form builder with data validation and pre processing","archived":false,"fork":false,"pushed_at":"2018-09-15T12:25:19.000Z","size":52,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-13T02:05:36.108Z","etag":null,"topics":["form","form-builder","form-validation","framework-agnostic","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/misantron.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-09-18T09:39:52.000Z","updated_at":"2018-09-15T12:24:56.000Z","dependencies_parsed_at":"2022-08-22T11:31:22.290Z","dependency_job_id":null,"html_url":"https://github.com/misantron/bricks","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/misantron/bricks","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/misantron%2Fbricks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/misantron%2Fbricks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/misantron%2Fbricks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/misantron%2Fbricks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/misantron","download_url":"https://codeload.github.com/misantron/bricks/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/misantron%2Fbricks/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278542675,"owners_count":26004061,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-05T02:00:06.059Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["form","form-builder","form-validation","framework-agnostic","php"],"created_at":"2024-12-04T18:16:59.349Z","updated_at":"2025-10-06T00:53:18.181Z","avatar_url":"https://github.com/misantron.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Bricks\n\n[![Build Status](http://img.shields.io/travis/misantron/bricks.svg?style=flat-square)](https://travis-ci.org/misantron/bricks)\n[![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/misantron/bricks.svg?style=flat-square)](https://scrutinizer-ci.com/g/misantron/bricks)\n[![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/g/misantron/bricks.svg?style=flat-square)](https://scrutinizer-ci.com/g/misantron/bricks)\n[![Packagist](https://img.shields.io/packagist/v/misantron/bricks.svg?style=flat-square)](https://packagist.org/packages/misantron/bricks)\n[![PHP 7 Support](https://img.shields.io/badge/PHP%207-supported-blue.svg?style=flat-square)](https://github.com/misantron/bricks)\n\nFlexible form builder with data validation and pre processing.\n\n## Installation\n\nRun [Composer](https://getcomposer.org) from command line:\n\n```\ncomposer require misantron/bricks\n```\n\nOr add dependency to `composer.json`:\n\n```\n{\n    \"require\": {\n        \"misantron/bricks\": \"dev-master\"\n    }\n}\n```\n\n## Usage\n\nCreate a new form by inheriting `\\Bricks\\AbstractForm`. Abstract method `fields()` must be implemented with configuration array:\n\n```php\nclass SomeForm extends \\Bricks\\AbstractForm\n{\n    protected funtion fields(): array\n    {\n        return [\n            'foo' =\u003e [\n                'type' =\u003e 'string', // using for data type cast\n                'validators' =\u003e [\n                    'required' =\u003e true,\n                    'lengthMax' =\u003e 64,\n                ],\n            ],\n            'bar' =\u003e [\n                'type' =\u003e 'integer', // using for data type cast\n                'validators' =\u003e [\n                    'required' =\u003e true,\n                    'in' =\u003e function () {\n                        return [1, 2];\n                    }\n                ],\n                'cleanup' =\u003e true, // flag that field will be deleted from getData() method call response\n            ],\n        ];\n    }\n}\n```\n\nForm workflow inside application controller/service/etc.:\n\n```php\n$request = Request::fromGlobals(); // must implements \\Psr\\Http\\Message\\RequestInterface\n\n$default = [\n    'foo' =\u003e 'test',\n];\n\n$form = \\SomeForm::create()\n    -\u003esetData($default) // allows to pass an initial data before handling the request\n    -\u003ehandleRequest($request) // get data from the request and data processing\n    -\u003evalidate(); // data validation\n\n$data = $form-\u003egetData(); // extracting processed and validated data from form\n```\n\n## Built-in field types\n\n`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`\n\nCustom user type can be easily added:\n\n```php\nclass MyTransducer extends \\Bricks\\Data\\Transducer\n{\n    private funtion myType($value)\n    {\n        // your custom logic here\n    }\n}\n```\n\n## Built-in field validation rules\n\nSee [Valitron](https://github.com/vlucas/valitron) documentation.\nIf form data is not valid - `\\Bricks\\Exception\\ValidationException` will be thrown:\n\n```php\ntry {\n    $form-\u003evalidate();\n} catch (\\Bricks\\Exception\\ValidationException $e) {\n    var_dump($e-\u003egetData()); // getting fields error data\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmisantron%2Fbricks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmisantron%2Fbricks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmisantron%2Fbricks/lists"}