1. Go to this page and download the library: Download misantron/bricks library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
misantron / bricks example snippets
class SomeForm extends \Bricks\AbstractForm
{
protected funtion fields(): array
{
return [
'foo' => [
'type' => 'string', // using for data type cast
'validators' => [
' 'in' => function () {
return [1, 2];
}
],
'cleanup' => true, // flag that field will be deleted from getData() method call response
],
];
}
}
$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
class MyTransducer extends \Bricks\Data\Transducer
{
private funtion myType($value)
{
// your custom logic here
}
}