4

How can I use different databases in every single bundle of Symfony2 with Doctrine2?

FooBundle <- Database "Foo"

BarBundle <- Database "Bar"

1 Answer 1

6

This may help How to work with Multiple Entity Managers and Connections.

So you can define multiple Entity Managers related to your databases connections, you can then map your bundle(s) to the right Entity Manager.

The examples on the documentation are well explained.

doctrine:
    dbal:
        default_connection:   foo_connection
        connections:
            foo_connection:
                # ...
                # Foo connection parameters
                # ...
            bar_connection:
                # ...
                # Bar connection parameters
                # ...

    orm:
        default_entity_manager:   foo_manager
        entity_managers:
            foo_manager:
                connection:        foo_connection
                mappings:
                    FooBundle: ~
            bar_manager:
                connection:       bar_connection
                mappings:
                    BarBundle: ~
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.