0

In Symfony 5.4, I am using the Easyadmin bundle, but during the multiple connections, I am facing some challenges.

In doctrine.yaml file,

    doctrine:
    dbal:
        default_connection: default
        connections:
            default:
                # configure these for your database server
                url: '%env(resolve:DATABASE_URL)%'
                wrapper_class: App\DBAL\MultiDbConnectionWrapper
                driver: 'pdo_mysql'
                # server_version: '5.7'
                charset: utf8mb4

            label:
                # configure these for your database server
                url: '%env(resolve:DATABASE_LABEL_URL)%'
                wrapper_class: App\DBAL\MultiDbConnectionWrapper
                driver: 'pdo_mysql'
                # server_version: '5.7'
                charset: utf8mb4

            prod_scan:
                # configure these for your database server
                url: '%env(resolve:DATABASE_PROD_SCAN_URL)%'
                wrapper_class: App\DBAL\MultiDbConnectionWrapper
                driver: 'pdo_mysql'
                # server_version: '5.7'
                charset: utf8mb4

        # IMPORTANT: You MUST configure your server version,
        # either here or in the DATABASE_URL env var (see .env file)
        #server_version: '13'
    
    default_entity_manager: default
    entity_managers:
            default:
                connection: default
                mappings:
                    RefArticlePrefix:
                        is_bundle: false
                        type: annotation
                        dir: '%kernel.project_dir%/src/Entity/RefArticlePrefix'
                        prefix: 'App\Entity\RefArticlePrefix'
                        alias: RefArticlePrefix
                    QcUser:
                        is_bundle: false
                        type: annotation
                        dir: '%kernel.project_dir%/src/Entity/QcUser'
                        prefix: 'App\Entity\QcUser'
                        alias: QcUser
            label:
                connection: label
                mappings:
                    PrintArtLabAssoc:
                        is_bundle: false
                        type: annotation
                        dir: '%kernel.project_dir%/src/Entity/PrintArtLabAssoc'
                        prefix: 'App\Entity\PrintArtLabAssoc'
                        alias: PrintArtLabAssoc
            prod_scan:
                connection: prod_scan
                mappings:
                    Prodid:
                        is_bundle: false
                        type: annotation
                        dir: '%kernel.project_dir%/src/Entity/Prodid'
                        prefix: 'App\Entity\Prodid'
                        alias: Prodid
                    ProdidCposant:
                        is_bundle: false
                        type: annotation
                        dir: '%kernel.project_dir%/src/Entity/ProdidCposant'
                        prefix: 'App\Entity\ProdidCposant'
                        alias: ProdidCposant
when@test:
    doctrine:
        dbal:
            # "TEST_TOKEN" is typically set by ParaTest
            dbname_suffix: '_test%env(default::TEST_TOKEN)%'

when@prod:
    doctrine:
        orm:
            auto_generate_proxy_classes: false
            query_cache_driver:
                type: pool
                pool: doctrine.system_cache_pool
            result_cache_driver:
                type: pool
                pool: doctrine.result_cache_pool

    framework:
        cache:
            pools:
                doctrine.result_cache_pool:
                    adapter: cache.app
                doctrine.system_cache_pool:
                    adapter: cache.system     

Which is displaying the below error,

Unrecognized options "default_entity_manager, entity_managers" under "doctrine". Available options are "dbal", "form".

How can I resolve this error?

Thanx in advance.

is there any alternative for crud functionality, where the controller belongs to a different database?

  • The answers sort of answer your question. For future reference `bin/console config:dump-reference doctrine` will show you all your config options. It's somewhat verbose since doctrine has quite a bit of configuration but, with patience, you can see what options go where for any bundle. – Cerad Aug 10 '22 at 14:48

2 Answers2

0

These options have moved under orm. https://symfony.com/doc/5.4/doctrine/multiple_entity_managers.html

Okspen
  • 22
  • 5
  • 1
    Just for info, link only answers are frowned upon in stackoverflow and often attract down votes. Plus the options were never actually moved, they were always under orm dating back to the original release of Symfony 2.0. – Cerad Aug 12 '22 at 15:51
0

Okspen already gave the correct hint. Would like to extend this with an example how it would look like:

doctrine:
    orm:
        auto_generate_proxy_classes: false
        default_entity_manager: default // <--
        entity_managers: // <--
        default:
            connection: default
            ....
        query_cache_driver:
            type: pool
            pool: doctrine.system_cache_pool
alexktz
  • 48
  • 6