user4488093
user4488093

Reputation:

Two databases in the configuration symfony2

I'm trying to configure to work with two databases and I have such a configuration:

doctrine:
    dbal:
      connections:
        default:
          driver:   %database_driver%
          host:     %database_host%
          port:     %database_port%
          dbname:   %database_name%
          user:     %database_user%
          password: %database_password%
          charset:  UTF8
        zaweb:
          driver:  %database_driver%
          host:    %database_host%
          port:    %database_port%
          dbname:  "zyabypoel"
          user:    %database_user%
          password: %database_password%


      types:
          json: Sonata\Doctrine\Types\JsonType

    orm:
        default_entity_manager: default
        entity_managers:
            default:
              connection: default
            zaweb:
              connection: zaweb
              mappings:
                  ZaWebMenuBundle: ~
                  ZaWebGeoBundle: ~
                  ZaWebApiBundle: ~
                  ZaWebSiteBundle: ~
                  ZaWebAdminBundle: ~

        filters:
            softdeleteable:
                class: Gedmo\SoftDeleteable\Filter\SoftDeleteableFilter
                enabled: true
        result_cache_driver: apc
        auto_generate_proxy_classes: %kernel.debug%
        auto_mapping: true

When I run php app/console doctrine:database:create --connection=zaweb I get the error: Unrecognized options "filters, result_cache_driver, auto_mapping" under "doctrine.orm"

This error appeared when I added a second connection to that it was not. Why?

Upvotes: 0

Views: 557

Answers (1)

schemar
schemar

Reputation: 622

filters belongs inside doctrine.orm.entity_managers.manager. So you have to move this option to the right in your file, so it is not next to, but inside an entity manager.

auto_mapping and result_cache_driver also belong inside a concrete entity_manager, e.g. inside zaweb.

See here: http://symfony.com/doc/current/reference/configuration/doctrine.html

EDIT: Sorry, now I also messed up the indentation. It's fixed now. In the end it could actually look like this:

orm:
    default_entity_manager: default
    entity_managers:
        default:
            connection: default
        zaweb:
            connection: zaweb
            result_cache_driver: apc
            auto_mapping: true
            mappings:
                ZaWebMenuBundle: ~
                ZaWebGeoBundle: ~
                ZaWebApiBundle: ~
                ZaWebSiteBundle: ~
                ZaWebAdminBundle: ~
            filters:
                softdeleteable:
                    class: Gedmo\SoftDeleteable\Filter\SoftDeleteableFilter
                    enabled: true
    auto_generate_proxy_classes: %kernel.debug%

Upvotes: 1

Related Questions