2017 © Pedro Peláez
 

doctrine doctrine-schema-multi-mapping

Allow to use doctrine schema commands when multi mapping defined.

image

rezzza/doctrine-schema-multi-mapping

Allow to use doctrine schema commands when multi mapping defined.

  • Tuesday, October 6, 2015
  • by steph_py
  • Repository
  • 6 Watchers
  • 3 Stars
  • 546 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 1 Open issues
  • 1 Versions
  • 2 % Grown

The README.md

Doctrine Schema Multi Mapping

Installation on Symfony.

Activate the bundle in AppKernel:, (*1)

    if (in_array($this->getEnvironment(), array('test'))) {
        $bundles[] = new Rezzza\DoctrineSchemaMultiMapping\App\Bundle\DoctrineSchemaMultiMappingBundle();
    }

Usage

./app/console rezzza:doctrine-multi-mapping:schema:create --em=default  --env=test
./app/console rezzza:doctrine-multi-mapping:schema:update --em=default  --env=test
./app/console rezzza:doctrine-multi-mapping:schema:drop --em=default  --env=test

You should consider this bundle has not to be used in a production environment., (*2)

Why are we using it ?

In Doctrine2, if you define multiple mappings for the same entity then doctrine:schema:* commands will fail because it will try to create 2 SQL tables with the same name instead of combining all entities mappings representing the same entity from various points of view., (*3)

Example: Acme e-commerce application with many User entities

We want to express a User model in different bounded contexts., (*4)

Definition of User entity in Account bounded context

We have a \Acme\User\Account\User.php entity., (*5)

In this bounded context, we need to manage User authentication & signin so a (simple) mapping could be:, (*6)

    - id
    - username
    - password
    - first_name
    - last_name

Definition of User entity Cart bounded context

We have a \Acme\User\Cart\User.php entity., (*7)

In this bounded context, we don't have to bother with autentication concerns, we just need to know user's e-commerce relative informations., (*8)

    - id
    - first_name
    - last_name
    - is_first_order

This kind of application in your production environment could work with a shared database and you would have to manually define migrations, (*9)

With this example, Doctrine will have 2 times a definition for table user and will throw an exception., (*10)

This library merge the 2 entities mappings ONLY for doctrine:schema:* commands., (*11)

This bundle provide by this way 3 commands, to replace doctrine:schema:* command, you have to replace namespace by rezzza:doctrine-multi-mapping:schema:*., (*12)

Which doctrine mapping features are not supported?

At the moment, only inheritance type “none“ and “single_table“ are supported, feel free to make a PR to support others., (*13)

The Versions

06/10 2015

dev-master

9999999-dev https://github.com/rezzza/doctrine-schema-multi-mapping

Allow to use doctrine schema commands when multi mapping defined.

  Sources   Download

MIT

The Requires

 

test doctrine mapping