PHPackages                             addiks/symfony\_rdm - 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. [Database &amp; ORM](/categories/database)
4. /
5. addiks/symfony\_rdm

ActiveLibrary[Database &amp; ORM](/categories/database)

addiks/symfony\_rdm
===================

Helps with the use of domain driven design &amp; rich domain model in symfony/doctrine applications.

v3.6.6(1y ago)64.7k2GPL-3.0-or-laterPHPPHP ^8.0.0 || ^8.1.0CI failing

Since Jan 9Pushed 1y ago3 watchersCompare

[ Source](https://github.com/addiks/symfony_rdm)[ Packagist](https://packagist.org/packages/addiks/symfony_rdm)[ Docs](http://github.com/addiks/symfony_rdm)[ RSS](/packages/addiks-symfony-rdm/feed)WikiDiscussions master Synced today

READMEChangelog (10)Dependencies (13)Versions (73)Used By (0)

Symfony-RDM – Helper for using the Rich Domain Model in Symfony
===============================================================

[](#symfony-rdm--helper-for-using-the-rich-domain-model-in-symfony)

[![Build Status](https://camo.githubusercontent.com/b1a8b74c2f6700323bdeac2477457a6bca6a6f8a5f8ce2c64ac17013647088ba/68747470733a2f2f7472617669732d63692e6f72672f616464696b732f73796d666f6e795f72646d2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/addiks/symfony_rdm)[![Build Status](https://camo.githubusercontent.com/eb7efb564af975cbe95666a14a08496511ca75ab028fadb7e57fec4ad33ef66a/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f616464696b732f73796d666f6e795f72646d2f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/addiks/symfony_rdm/build-status/master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/53f3073b5a0244cf10c8613d258da3a81090e4a9ff1029ce399241fab4ef327c/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f616464696b732f73796d666f6e795f72646d2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/addiks/symfony_rdm/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/e30a18b9557f9df006a54dc42a09a7a3ba1f02e9145114ea0be3e09c1fba5703/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f616464696b732f73796d666f6e795f72646d2f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/addiks/symfony_rdm/?branch=master)

What
----

[](#what)

The goal of this project is to enrich the doctrine2-ORM mapping capabilities so that entities do not have to be developed *for* doctrine anymore, but make it possible to map **any** object from anywhere to a database using doctrine, even if it was not developed for that purpose. It add's a lot of new ways on how data can be mapped from the database to an object (and back).

The currently implemented features are the following:

- [Load (symfony-) services into entity fields.](Resources/doc/service_mapping.md)
- [Have a switch (choice) of which mapping to load into a field.](Resources/doc/choice_mapping.md)
- [Load an array with static keys into a field.](Resources/doc/array_mapping.md)
- [Load a list with dynamic length containing other mappings.](Resources/doc/list_mapping.md)
- [Load any object with it's own inner mappings into a field.](Resources/doc/object_mapping.md) (You can map the same class in different ways.)
- [Have any mapping nullable.](Resources/doc/nullable_mapping.md)
- [Have a mapping always map to *NULL*.](Resources/doc/null_mapping.md)
- [Import mapping from another file.](Resources/doc/import_mapping.md)

Each of these can be combined with any other, allowing for extremely dynamic ORM mapping capabilities.

How
---

[](#how)

It hooks into the events of doctrine and hydrates the marked fields with the described values. There are multiple ways of defining which mappings should be in what fields of the services: Per annotations, YAML, XML, PHP or Static PHP. YAML-Mapping is not fully implemented yet and may be removed soon.

I would suggest you to use the XML (or YAML) mapping because entities should be framework-agnostic. I personally prefer XML over YAML because with XML you at least have a schemata while with yaml you often have to guess what keys are allowed, what all the keys mean and who actually uses them. For more detauls see the linked documentations above.

Setup
-----

[](#setup)

To enable this functionality first install the project via composer (symfony normally comes with composer) using the following command: **composer require addiks/symfony\_rdm**

Then [register the bundle in your symfony-application](http://symfony.com/doc/current/bundles.html). Prior to symfony-4.0 this is done in the file "app/AppKernel.php" inside the method "registerBundles". From 4.0 onwards this is done in the file "config/bundles.php". (If you know how to automate this, please let me know.)

Symfony 2.x &amp; 3.x:

```
// app/AppKernel.php
public function registerBundles()
{
    $bundles = array(
        new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
        # ...
        new Addiks\RDMBundle\AddiksRDMBundle(), #  ['all' => true],
    …
    Addiks\RDMBundle\AddiksRDMBundle::class => ['all' => true], #
