PHPackages                             chamber-orchestra/form-bundle - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. chamber-orchestra/form-bundle

ActiveSymfony-bundle[HTTP &amp; Networking](/categories/http)

chamber-orchestra/form-bundle
=============================

Symfony 8 bundle for JSON-first API form handling with controller traits, data transformers, Doctrine validation, and RFC 9457 problem details error responses

v8.0.11(2mo ago)2535↑100%11MITPHPPHP ^8.5CI passing

Since Dec 31Pushed 2mo agoCompare

[ Source](https://github.com/chamber-orchestra/form-bundle)[ Packagist](https://packagist.org/packages/chamber-orchestra/form-bundle)[ Docs](https://github.com/chamber-orchestra/form-bundle)[ RSS](/packages/chamber-orchestra-form-bundle/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (34)Versions (16)Used By (1)

[![PHP Composer](https://github.com/chamber-orchestra/form-bundle/actions/workflows/php.yml/badge.svg)](https://github.com/chamber-orchestra/form-bundle/actions/workflows/php.yml)[![Latest Stable Version](https://camo.githubusercontent.com/b13016a6dd76039e1fa08cb4b8fcedb989e4cc8b5ffcd6c62943c5c9d7935636/68747470733a2f2f706f7365722e707567782e6f72672f6368616d6265722d6f72636865737472612f666f726d2d62756e646c652f76)](https://packagist.org/packages/chamber-orchestra/form-bundle)[![License](https://camo.githubusercontent.com/a12b47d83bb46e7ba7ce510a7af5c11ad34230d2941642761d401431c7aeb20f/68747470733a2f2f706f7365722e707567782e6f72672f6368616d6265722d6f72636865737472612f666f726d2d62756e646c652f6c6963656e7365)](https://packagist.org/packages/chamber-orchestra/form-bundle)[![PHP 8.5](https://camo.githubusercontent.com/38189c74fa19d38a84282702897dcd5bf0e54f8ee6be5cb02aa9a3a1f5711862/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e352d3737374242343f6c6f676f3d706870266c6f676f436f6c6f723d7768697465)](https://camo.githubusercontent.com/38189c74fa19d38a84282702897dcd5bf0e54f8ee6be5cb02aa9a3a1f5711862/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e352d3737374242343f6c6f676f3d706870266c6f676f436f6c6f723d7768697465)[![Symfony 8](https://camo.githubusercontent.com/029babe1877b30127823cca997efd987b7a8e3ceb0cd835916734d01cdc6da21/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53796d666f6e792d382d3030303030303f6c6f676f3d73796d666f6e79266c6f676f436f6c6f723d7768697465)](https://camo.githubusercontent.com/029babe1877b30127823cca997efd987b7a8e3ceb0cd835916734d01cdc6da21/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53796d666f6e792d382d3030303030303f6c6f676f3d73796d666f6e79266c6f676f436f6c6f723d7768697465)[![PHPStan Max](https://camo.githubusercontent.com/2a2140de4b2076b55ea6fadf5331a9133bf4232c9ca5d4acba5cc6494763d2cc/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6d61782d627269676874677265656e3f6c6f676f3d706870266c6f676f436f6c6f723d7768697465)](https://camo.githubusercontent.com/2a2140de4b2076b55ea6fadf5331a9133bf4232c9ca5d4acba5cc6494763d2cc/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6d61782d627269676874677265656e3f6c6f676f3d706870266c6f676f436f6c6f723d7768697465)[![PHP-CS-Fixer](https://camo.githubusercontent.com/79ef22c79ba67ae1d7b3b536528934839121cc2766eaa71109c5d0a01a08271d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d2d43532d2d46697865722d2545322539432539332d627269676874677265656e3f6c6f676f3d706870266c6f676f436f6c6f723d7768697465)](https://camo.githubusercontent.com/79ef22c79ba67ae1d7b3b536528934839121cc2766eaa71109c5d0a01a08271d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d2d43532d2d46697865722d2545322539432539332d627269676874677265656e3f6c6f676f3d706870266c6f676f436f6c6f723d7768697465)[![Code Style: PER-CS & Symfony](https://camo.githubusercontent.com/02000ee5753f2985f3e84b739b7aea40a464a12773dc6ee6927b221179895b03/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f436f64652532305374796c652d5045522d2d435325323025323625323053796d666f6e792d626c75653f6c6f676f3d73796d666f6e79266c6f676f436f6c6f723d7768697465)](https://camo.githubusercontent.com/02000ee5753f2985f3e84b739b7aea40a464a12773dc6ee6927b221179895b03/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f436f64652532305374796c652d5045522d2d435325323025323625323053796d666f6e792d626c75653f6c6f676f3d73796d666f6e79266c6f676f436f6c6f723d7768697465)

ChamberOrchestra Form Bundle
============================

[](#chamberorchestra-form-bundle)

A Symfony 8 bundle that simplifies JSON-first form handling for REST APIs. It provides controller traits for the submit/validate/response flow, specialized API form types with CSRF disabled, reusable data transformers, Doctrine-backed uniqueness validation, and structured error responses following [RFC 9457 (Problem Details for HTTP APIs)](https://www.rfc-editor.org/rfc/rfc9457).

Features
--------

[](#features)

- **Controller traits** (`FormTrait`, `ApiFormTrait`) for submit/validate/response flow with null-safe request handling
- **JSON payload handling** for mutation requests with automatic merging of uploaded files
- **API form base types** (`QueryForm`, `MutationForm`) with CSRF disabled and empty block prefixes for clean JSON payloads
- **Custom form types**: `BooleanType`, `TimestampType`, `HiddenEntityType` with secure query builder parameterization
- **Data transformers** for booleans, Unix timestamps, comma-separated arrays, and JSON strings
- **RFC 9457 problem details** via `ValidationFailedView` with structured violations for consistent API error responses
- **Translatable error normalizer** (`ProblemNormalizer`) for localized exception messages in problem detail responses
- **`UniqueField` validation constraint** for Doctrine repositories with multi-field checks, closure-based exclusions, and custom normalizers
- **`TelExtension`** to strip non-digit characters from phone number input
- **`CollectionUtils`** for syncing Doctrine collections (add new / remove stale items)

Requirements
------------

[](#requirements)

- PHP ^8.5
- Symfony 8.0 components (framework-bundle, form, validator, config, dependency-injection, runtime, translation, clock)
- Doctrine ORM 3.6
- [chamber-orchestra/view-bundle](https://github.com/chamber-orchestra/view-bundle) 8.0

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

[](#installation)

```
composer require chamber-orchestra/form-bundle:8.0.*
```

Enable the bundle in `config/bundles.php`:

```
return [
    // ...
    ChamberOrchestra\FormBundle\ChamberOrchestraFormBundle::class => ['all' => true],
];
```

Usage
-----

[](#usage)

### Controller Traits

[](#controller-traits)

Use `FormTrait` for standard HTML form submissions and `ApiFormTrait` for JSON API endpoints.

`handleFormCall()` accepts a form class or instance, handles the request, and returns a view or response. `handleApiCall()` does the same for API endpoints -- it automatically parses JSON payloads for `MutationForm` types and merges uploaded files.

`onFormSubmitted()` checks validity, returns a `ValidationFailedView` on failure, or invokes the callback on success:

```
use ChamberOrchestra\FormBundle\ApiFormTrait;
use ChamberOrchestra\ViewBundle\View\ViewInterface;
use Symfony\Component\HttpFoundation\Request;

final class SearchCourseAction
{
    use ApiFormTrait;

    public function __invoke(Request $request): ViewInterface
    {
        $form = $this->createForm(SearchCourseForm::class);
        $form->submit($request->query->all());

        return $this->onFormSubmitted($form, function (SearchCourseData $dto) use ($request) {
            $entities = $this->er->searchCourses(
                $pagination = $this->getPagination(['per_page_limit' => $this->getPerPageLimit($request)]),
                $dto->query,
                $dto->brands,
                $dto->topics,
                $dto->products,
                $dto->durations
            );

            return new PaginatedView($entities, $pagination, CourseView::class);
        });
    }
}
```

### API Form Types

[](#api-form-types)

Extend `QueryForm` for GET requests or `MutationForm` for POST/PUT/PATCH requests. Both disable CSRF protection and use empty block prefixes for clean JSON input/output.

### Data Transformers

[](#data-transformers)

TransformerDescription`TextToBoolTransformer`Converts `"true"`, `"1"`, `"yes"` to boolean`DateTimeToNumberTransformer`Converts Unix timestamps to `DateTimeInterface` objects`ArrayToStringTransformer`Converts arrays to/from comma-separated strings`JsonStringToArrayTransformer`Parses JSON strings to arrays (handles empty strings)### HiddenEntityType

[](#hiddenentitytype)

Loads Doctrine entities by ID from a hidden form field. Supports a custom `query_builder` option with secure parameterized queries.

### UniqueField Validator

[](#uniquefield-validator)

Validates field uniqueness against Doctrine repositories. Supports multiple fields, closure-based exclusions, custom normalizers, and targeted error paths.

### ProblemNormalizer

[](#problemnormalizer)

Extends Symfony's `ProblemNormalizer` to translate exception messages when the exception implements `TranslatableExceptionInterface`. This ensures localized error messages in RFC 9457 problem detail responses.

Response Views
--------------

[](#response-views)

ViewHTTP StatusDescription`SuccessView`200Empty success response`ValidationFailedView`422Form validation errors with structured `ViolationView` items`FailureView`ConfigurableGeneric error response`RedirectView`301/302Redirect response for AJAX requests`SuccessHtmlView`200HTML fragment response for AJAX requestsTesting
-------

[](#testing)

Install dependencies and run the full test suite:

```
composer install
./vendor/bin/phpunit
```

The integration test kernel (`tests/Integrational/TestKernel.php`) boots a minimal Symfony application with in-memory SQLite for Doctrine tests.

License
-------

[](#license)

MIT

###  Health Score

49

—

FairBetter than 94% of packages

Maintenance92

Actively maintained with recent releases

Popularity22

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

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

Total

11

Last Release

70d ago

PHP version history (2 changes)v8.0.2PHP ^8.4

v8.0.7PHP ^8.5

### Community

Maintainers

![](https://www.gravatar.com/avatar/44037eb1c8dc2c4fa9871ac213653f33e22a9348dcec7132df07cc71933f2a2e?d=identicon)[wtorsi](/maintainers/wtorsi)

---

Top Contributors

[![wtorsi](https://avatars.githubusercontent.com/u/2115840?v=4)](https://github.com/wtorsi "wtorsi (15 commits)")

---

Tags

apicsrfdata-transformerdoctrineerror-handlingformform-handlingform-typejsonjson-apiphpproblem-detailsrestrest-apirfc9457symfonysymfony-bundlesymfony8validationjsonapisymfonyvalidationrestdoctrineformREST APIJSON-APIcsrfproblem detailserror handlingSymfony Bundleform handlingsymfony8data-transformerForm Typerfc9457

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/chamber-orchestra-form-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/chamber-orchestra-form-bundle/health.svg)](https://phpackages.com/packages/chamber-orchestra-form-bundle)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M647](/packages/sylius-sylius)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M151](/packages/sulu-sulu)[contao/core-bundle

Contao Open Source CMS

1231.6M2.3k](/packages/contao-core-bundle)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.2M385](/packages/shopware-core)[web-auth/webauthn-framework

FIDO2/Webauthn library for PHP and Symfony Bundle.

50570.7k1](/packages/web-auth-webauthn-framework)

PHPackages © 2026

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