Symfony2 - Entity Entity Subdirectories

Basically, I have a code branch that connects to three different entity managers (and then three different MySQL databases). Unfortunately, two databases have tables that are called the same, so I can’t have all the entities in one directory, and an identifier for a structure to avoid this.

So my question is this: how would I configure it so that I can have a single set of objects with subdirectories under Entity\andResources\config\doctrine\

eg.

Acme\EntityBundle\Entity\DB1\Test.php
Acme\EntityBundle\Entity\DB1\Acme.php
Acme\EntityBundle\Entity\DB2\Test.php
Acme\EntityBundle\Entity\DB2\Foo.php
Acme\EntityBundle\Entity\DB3\Bar.php

same idea for Resources\config\doctrine\

The configurations are very vague on what to do here ...

+5
source share
2 answers

, . .

. .

:

#app/config/config.yml
doctrine:
    orm:
        auto_generate_proxy_classes: %kernel.debug%
        auto_mapping: true
        mappings:
            AcmeDB1:
                type:       xml
                is_bundle:  false
                dir:        %kernel.root_dir%/../src/Acme/Entity/DB1/config
                prefix:     Acme\Entity\DB1
                alias:      AcmeDB1
            AcmeDB2:
                type:       xml
                is_bundle:  false
                dir:        %kernel.root_dir%/../src/Acme/Entity/DB2/config
                prefix:     Acme\Entity\DB2
                alias:      AcmeDB2

:

  • dir , , , .
  • alias , , AcmeDB1: User
+4

.

, :

  • Bundle/Entity/DB1/User.php
  • Bundle/Entity/DB2/User.php

(.yml , )

  • Bundle/Resources/config/doctrine/DB1.User.orm.yml
  • Bundle/Resources/config/doctrine/DB2.User.orm.yml
+4

All Articles