Yoot
Yoot

Reputation: 657

Symfony 2 : Generate entities from multiple databases

Here is my config file:

# Doctrine Configuration
doctrine:
    dbal:
        default_connection: flux
        connections:
            flux:
                driver:   %db_flux_driver%
                host:     %db_flux_host%
                port:     %db_flux_port%
                dbname:   %db_flux_name%
                user:     %db_flux_user%
                password: %db_flux_password%
                charset:  UTF8
            commun:
                driver:   %db_commun_driver%
                host:     %db_commun_host%
                port:     %db_commun_port%
                dbname:   %db_commun_name%
                user:     %db_commun_user%
                password: %db_commun_password%
                charset:  UTF8
    orm:
        default_entity_manager: default
        entity_managers:
            default:
                connection: flux
                mappings:
                    CreatisSaisieBundle: ~
            commun:
                connection: commun
                mappings:
                    CreatisSaisieBundle: ~

As you can see I'm using 2 connections.

I've been using the app/console doctrine:mapping:convert xml command line to generate my orm xml files but that only generated the entities from my default connection (flux).

Is there an option that allows to generate entities from a specific connection, or from all of them?

Upvotes: 4

Views: 1925

Answers (1)

le_yougue
le_yougue

Reputation: 36

I've test this command to create entity for my app, it seems to work:

php app/console doctrine:mapping:convert --em="ENTITY_MANAGER" --from-database yml ./src/NAMESPACE/NAMEBundle/Resources/config/doctrine/metadata/orm

Upvotes: 2

Related Questions