PHPackages                             mikesimonson/symfony-form-value-object-mapper - 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. mikesimonson/symfony-form-value-object-mapper

ActiveLibrary

mikesimonson/symfony-form-value-object-mapper
=============================================

A library that can instantiate automatically value object mapped by Symfony forms despite having a constructor with arguments.

46PHP

Since Mar 30Pushed 9y agoCompare

[ Source](https://github.com/mikeSimonson/symfony-form-value-object-mapper)[ Packagist](https://packagist.org/packages/mikesimonson/symfony-form-value-object-mapper)[ RSS](/packages/mikesimonson-symfony-form-value-object-mapper/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Symfony Form Value Object Mapper
================================

[](#symfony-form-value-object-mapper)

[![Build Status](https://camo.githubusercontent.com/a0e1575480a10a00a12fe59984edd63363400d380e24795425ee6e27a2eec0ec/68747470733a2f2f7472617669732d63692e6f72672f6d696b6553696d6f6e736f6e2f73796d666f6e792d666f726d2d656e746974792d6d61707065722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/mikeSimonson/symfony-form-entity-mapper)[![Code Coverage](https://camo.githubusercontent.com/e3d6e46a09550b44e84c097cea05af5d17426e4a349cfa18ebeb5b23c8edc0a9/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d696b6553696d6f6e736f6e2f73796d666f6e792d666f726d2d656e746974792d6d61707065722f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/mikeSimonson/symfony-form-entity-mapper/?branch=master)

Motivation
----------

[](#motivation)

Value object usage with the Symfony form component. There is a [great post](https://webmozart.io/blog/2015/09/09/value-objects-in-symfony-forms/) from Webmozart explaining how to use the Symfony form component with value object. But sometimes people might get discourage to use value object because they now need to do the mapping between the object and the form manually. It can look daunting when the number of properties of the object is high.

This library intend to fix 90% of that issue by providing automatic mapping in most of the cases. See the requirements part.

In the 10% left, it still make more sense to do the mapping manually than do try to make a library that has to do magic incantation to guess the user need.

Install
-------

[](#install)

```
composer require mikesimonson/symfony-form-value-object-mapper
```

Usage
-----

[](#usage)

In any form that requires it you can use

```
$builder->setDataMapper(new FormMapper());
```

Requirement to use this Mapper:
-------------------------------

[](#requirement-to-use-this-mapper)

- Having entities
- Having getters and setters on those entities
- The name of the form elements must match the name of the properties in the entity
- The name of the constructor parameters must match the name of the entities property
- If yout throw an exception in case of validation failure it needs to extends InvalidArgumentException
- Tests for your forms that use it. If you change a property name in your value object the form will break. (Although it's also true with the default form mapper from the symfony form)

Limitation:
-----------

[](#limitation)

Right now this mapper doesn't work with the collectionType field. PR are welcome.

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/c2c3672cf4687fd66d48ad82fd08cf52051353c4e693b2ff151e75d4372cdaba?d=identicon)[mikeSimonson](/maintainers/mikeSimonson)

---

Top Contributors

[![mikeSimonson](https://avatars.githubusercontent.com/u/907613?v=4)](https://github.com/mikeSimonson "mikeSimonson (51 commits)")

### Embed Badge

![Health badge](/badges/mikesimonson-symfony-form-value-object-mapper/health.svg)

```
[![Health](https://phpackages.com/badges/mikesimonson-symfony-form-value-object-mapper/health.svg)](https://phpackages.com/packages/mikesimonson-symfony-form-value-object-mapper)
```

PHPackages © 2026

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