PHP code example of contenir / contenir-formbuilder-mezzio

1. Go to this page and download the library: Download contenir/contenir-formbuilder-mezzio 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/ */

    

contenir / contenir-formbuilder-mezzio example snippets


// config/pipeline.php
$app->pipe(Mezzio\Session\SessionMiddleware::class);
$app->pipe(Mezzio\Router\Middleware\RouteMiddleware::class);

use Contenir\FormBuilder\Mezzio\Render\FormBlockRenderer;
use Laminas\Diactoros\Response\HtmlResponse;
use Mezzio\Template\TemplateRendererInterface;

final readonly class ContactPageHandler implements RequestHandlerInterface
{
    public function __construct(
        private FormBlockRenderer $forms,
        private TemplateRendererInterface $templates,
    ) {}

    public function handle(ServerRequestInterface $request): ResponseInterface
    {
        return new HtmlResponse($this->templates->render('app::contact', [
            'form' => $this->forms->render($request, 'contact'),
        ]));
    }
}