PHPackages                             samson/dataview-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. [Templating &amp; Views](/categories/templating)
4. /
5. samson/dataview-bundle

ActiveSymfony-bundle[Templating &amp; Views](/categories/templating)

samson/dataview-bundle
======================

Make configuring different serialization views for your entities easy and maintainable.

2.0.0(12y ago)88651MITPHPPHP &gt;=5.3.3

Since Jul 18Pushed 11y ago13 watchersCompare

[ Source](https://github.com/SamsonIT/DataViewBundle)[ Packagist](https://packagist.org/packages/samson/dataview-bundle)[ Docs](https://github.com/SamsonIT/DataViewBundle)[ RSS](/packages/samson-dataview-bundle/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (1)Versions (5)Used By (1)

README
======

[](#readme)

Example of use
--------------

[](#example-of-use)

```
// class
class SampleDataView extends AbstractType
{
    public function getName()
    {
        return 'sample';
    }

    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('name_of_key', 'type_of_key', array('property_path' => 'optionalPath', /** other options */))
            ->add('children', 'collection', array('type' => new ChildDataView())
        ;

        $builder->addEventListener(FormEvents::PRE_SET_DATA, function(FormEvent $e) {
            $e->getForm()->add('new_key', 'type_of_key', array('mapped' => false, 'data' => $e->getData()->getSomeCustomData());
        }

        // or you can use this convenience method:
        $builder->addFixed('new_key', 'type_of_key', function($data) { return $data->getSomeCustomData(); });
    }
}

// use
$view = $container->get('samson.dataview.factory')->create(new SampleDataView(), $sample);
$data = $view->createView()->getData();

// $data is now something like:
// array( 'name_of_key' => 'value_of_$entity->getOptionalPath()', 'children' => array(array(), array(), array(), 'etc' ), 'new_key' => 'value_of_$entity->getSomeCustomData()' );
```

If your object is a doctrine entity, you can let the guessers so the work for you:

```
class SampleDataView extends AbstractType
{
    public function getName()
    {
        return 'sample';
    }

    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('name_of_key')
            ->add('children')
        ;
    }
}
```

By default, if a one-to-many or many-to-many collection is encountered, the type "collection" will be setup with the option `type` set to `entity`. The entity type by default will try to convert your entity to an array with keys `id` and `name`, the latter being the object cast to string.

Introduction
------------

[](#introduction)

The DataViewBundle is based in great upon the Form component in symfony. It makes use of the FormView part to convert an object scheme into a basic array, making full use of the flexibility the Form component offers.

A problem often encountered, for example, is having a situation where you want to serialize a "Project" entity with all it's "Product" children in one controller, and a "Product" entity with it's "Product" parent in the other. In order to prevent an endless serialization loop, either make use of the options to tell each type what to include and what not, or simply add the relevant fields to the View from the controller.

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 93.8% 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 ~82 days

Total

4

Last Release

4439d ago

Major Versions

1.0.x-dev → 2.0.02014-03-21

PHP version history (2 changes)1.0.0PHP &gt;=5.3.0

2.0.0PHP &gt;=5.3.3

### Community

Maintainers

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

---

Top Contributors

[![Burgov](https://avatars.githubusercontent.com/u/417674?v=4)](https://github.com/Burgov "Burgov (15 commits)")[![SamsonIT-Jelle](https://avatars.githubusercontent.com/u/47599676?v=4)](https://github.com/SamsonIT-Jelle "SamsonIT-Jelle (1 commits)")

---

Tags

symfonyserializerview

### Embed Badge

![Health badge](/badges/samson-dataview-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/samson-dataview-bundle/health.svg)](https://phpackages.com/packages/samson-dataview-bundle)
```

###  Alternatives

[a2lix/auto-form-bundle

Automate form building

873.8M11](/packages/a2lix-auto-form-bundle)[nucleos/antispam-bundle

This bundle provides some basic features to reduce spam in symfony forms.

52105.1k](/packages/nucleos-antispam-bundle)[boekkooi/jquery-validation-bundle

Jquery form validation bundle for symfony 2

2773.9k1](/packages/boekkooi-jquery-validation-bundle)[craue/formflow-demo-bundle

Example code showcasing the features of CraueFormFlowBundle.

298.5k](/packages/craue-formflow-demo-bundle)

PHPackages © 2026

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