contenir / contenir-formbuilder-laminas-mvc
Laminas MVC adapter for contenir/contenir-formbuilder — Laminas\Db loader, view helper, submit controller, Module + ConfigProvider.
Package info
github.com/contenir/contenir-formbuilder-laminas-mvc
pkg:composer/contenir/contenir-formbuilder-laminas-mvc
Requires
- php: ~8.3.0 || ~8.4.0 || ~8.5.0
- contenir/contenir-formbuilder: ^2.2
- laminas/laminas-db: ^2.17
- laminas/laminas-form: ^3.20
- laminas/laminas-http: ^2.19
- laminas/laminas-mail: ^2.22
- laminas/laminas-mime: ^2.12
- laminas/laminas-mvc: ^3.8
- laminas/laminas-servicemanager: ^3.0
- laminas/laminas-session: ^2.16
- laminas/laminas-stdlib: ^3.21
- laminas/laminas-view: ^2.30
- psr/container: ^1.1 || ^2.0
- psr/log: ^1.0 || ^2.0 || ^3.0
Requires (Dev)
- contenir/contenir-storage: ^2.2
- infection/infection: ^0.34.1
- laminas/laminas-i18n: ^2.32
- php-db/phpdb-qa-tools: 0.1.x-dev
- phpunit/phpunit: ^11.5.42
Suggests
- contenir/contenir-storage: Enables the file field type: register a Contenir\Storage\StorageManager service and uploads are stored on its default profile.
Provides
None
Conflicts
- laminas/laminas-uri: <2.14
Replaces
- contenir/formbuilder-laminas-mvc: v2.2.0
This package is auto-updated.
Last update: 2026-10-06 00:51:39 UTC
README
Formerly contenir/formbuilder-laminas-mvc; the old package is abandoned in favour of this one.
Laminas MVC adapter for contenir/contenir-formbuilder.
It wires the framework-agnostic form-builder engine into a laminas-mvc site:
LaminasDbFormLoaderreads form definitions from the forms schema through laminas-db, one query per level.SubmitControllerhandlesPOST /forms/submit/{slug}: validation, spam trap, redirect or JSON response, and a one-shot stash so the form can be re-shown with errors after a redirect.- Registrars store the entry (
StoreSubmissionRegistrar), send email notifications (EmailNotificationRegistrar) and fire webhooks. - View helpers render a form (
formMarkup) and read the stash (formStashedState). ModuleandConfigProviderwith factories for all of it.
Requirements
- PHP 8.3, 8.4 or 8.5
contenir/contenir-formbuilder2.2+ (use 2.0.x of this package forcontenir/formbuilder0.1, and 2.1.x forcontenir/formbuilder2.1)- laminas-mvc 3.8+, laminas-db 2.17+, laminas-form, laminas-view, laminas-session, laminas-mail
- A database with the forms schema (
tests/install-forms.sqlite.sqlis the SQLite version) - Optional:
contenir/contenir-storage2.2+, registered asContenir\Storage\StorageManager, for file uploads
Installation
composer require contenir/contenir-formbuilder-laminas-mvc
The module registers itself through extra.laminas.module and
laminas-component-installer. Without the installer, add it to
config/modules.config.php:
'Contenir\FormBuilder\Laminas\Mvc',
The 0.x releases, which support PHP 8.1, remain available from the 0.x
branch and v0.* tags; see UPGRADE-2.0.md.
Usage
The controller loads the definition and builds the form; the template only renders.
use Contenir\FormBuilder\Laminas\Mvc\Loader\LaminasDbFormLoader; use Contenir\FormBuilder\Service\FormBuilderService; final class ContactController extends AbstractActionController { public function __construct( private LaminasDbFormLoader $loader, private FormBuilderService $builder, ) {} public function indexAction(): ViewModel { $definition = $this->loader->loadBySlug('contact'); $form = $this->builder->build($definition); return new ViewModel([ 'definition' => $definition, 'form' => $form, 'isSuccess' => $this->params()->fromQuery('submit') === 'contact', ]); } }
<?php $stashed = $this->formStashedState($definition->slug); ?> <?php if ($stashed !== null): ?> <?php $form->setData($stashed['values']); $form->setMessages($stashed['errors']); ?> <?php endif ?> <?php if ($isSuccess): ?> <div class="form-success">Thank you.</div> <?php else: ?> <?= $this->formMarkup($definition, $form) ?> <?php endif ?>
The rendered form posts to /forms/submit/{slug}. See docs/:
| Page | Covers |
|---|---|
| Configuration | The formbuilder config keys and registered services |
| Loading forms | LaminasDbFormLoader, the schema |
| Submitting | SubmitController, success modes, JSON responses, FormStateStash |
| Registrars | StoreSubmissionRegistrar, LaminasDbEntryRepository, EmailNotificationRegistrar, webhooks |
| Rendering | formMarkup and formStashedState helpers, Render\FormMarkup |
Development
The QA toolchain is php-db/phpdb-qa-tools.
Mago is a standalone binary, installed
separately (brew install mago).
composer check # everything below composer cs-check # mago format --check && mago lint composer static-analysis # mago analyze composer test # unit suite: stubs and in-memory session, no database composer test-integration # integration suite: in-memory SQLite with the forms schema composer test-coverage # both suites, clover.xml for Codecov composer mutation-test # Infection over both suites (needs Xdebug or PCOV)
License
MIT. See LICENSE.