且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

与symfony中的原则的多重联系2.3

更新时间:2023-11-19 21:20:10

我不知道为什么/如何工作



这里是代码:

  orm:
auto_generate_proxy_classes:%kernel.debug%
entity_managers :
extranet:
naming_strategy:doctrine.orm.naming_strategy.underscore
auto_mapping:true
crawl:
naming_strategy:doctrine.orm.naming_strategy.underscore
连接:抓取
映射:
DbBccCrawlBundle:〜

事情是我尝试一开始,它失败了(X类没有找到...)



如果有人有了探索,我会很乐意阅读它



无论如何



这是问题的第二部分,这里是begening:
当我尝试与doctrine 的多重连接时,在链配置的命名空间中找不到类X


So I'm trying to do a multiple connection with doctrine in my symfony project.

First, I was only using one database, then I needed to add another.

this was before :

# Doctrine Configuration
doctrine:
  dbal:
    default_connection: extranet
    connections:
        extranet:
            driver:   pdo_mysql
            host:     "%db_extranet_host%"
            port:     "%db_extranet_port%"
            dbname:   "%db_extranet_name%"
            user:     "%db_extranet_user%"
            password: "%db_extranet_password%"
            charset:  UTF8
orm:
    auto_generate_proxy_classes: "%kernel.debug%"
    entity_managers:
        extranet:
            naming_strategy: doctrine.orm.naming_strategy.underscore
            auto_mapping: true

and it was working fine

THEN I added the "crawl" database :

# Doctrine Configuration
doctrine:
  dbal:
    default_connection: extranet
    connections:
        extranet:
            driver:   pdo_mysql
            host:     "%db_extranet_host%"
            port:     "%db_extranet_port%"
            dbname:   "%db_extranet_name%"
            user:     "%db_extranet_user%"
            password: "%db_extranet_password%"
            charset:  UTF8
        crawl:
            driver:   pdo_mysql
            host:     "%db_crawl_host%"
            port:     "%db_crawl_port%"
            dbname:   "%db_crawl_name%"
            user:     "%db_crawl_user%"
            password: "%db_crawl_password%"
            charset:  UTF8
orm:
    auto_generate_proxy_classes: "%kernel.debug%"
    default_entity_manager: extranet
    entity_managers:
        extranet:
            connection: extranet
            naming_strategy: doctrine.orm.naming_strategy.underscore
            mappings:
                AppBundle: ~
        crawl:
            connection: crawl
            naming_strategy: doctrine.orm.naming_strategy.underscore
            mappings:
                DbBccCrawlBundle: ~

I got rid of the auto_mapping & added few things

BUT, now I lost connection to extranet (users can't loggin anymore for example)

Any ideas? (and thanks if you read that far ;) )

EDIT

following http://symfony.com/doc/2.3/reference/configuration/doctrine.html#mapping-entities-outside-of-a-bundle I tried to have the same syntax :

orm:
    # auto_generate_proxy_classes: "%kernel.debug%"
    default_entity_manager: extranet
    # auto_mapping: true
    mappings:
        AppBundle:
            type: annotation
            dir: '%kernel.root_dir%/../src/AppBundle/Entity'
            prefix: AppBundle\Entity
            alias: App
        DbBccCrawlBundle:
            type: annotation
            dir: '%kernel.root_dir%/../src/DbBccCrawlBundle/Entity'
            prefix: DbBccCrawlBundle\Entity
            alias: Crawl

still doesn't work....

EDIT 2

orm:
    auto_generate_proxy_classes: "%kernel.debug%"
    default_entity_manager: extranet
    entity_managers:
        auto_mapping: true
        extranet:
            connection: extranet
            naming_strategy: doctrine.orm.naming_strategy.underscore
            mappings:
                AppBundle:
                    type:   annotation
                    # dir:    '%kernel.root_dir%/../src/AppBundle/Entity'
                    # prefix: AppBundle\Entity
                    alias:  App
        crawl:
            connection: crawl
            naming_strategy: doctrine.orm.naming_strategy.underscore
            mappings:
                DbBccCrawlBundle:
                    type:   annotation
                    # dir:    '%kernel.root_dir%/../src/DbBccCrawlBundle/Entity'
                    # prefix: DbBccCrawlBundle\Entity
                    alias:  Crawl

not working either

I donno why/how but it works

here's the code :

orm:
    auto_generate_proxy_classes: "%kernel.debug%"
    entity_managers:
        extranet:
            naming_strategy: doctrine.orm.naming_strategy.underscore
            auto_mapping: true
        crawl:
            naming_strategy: doctrine.orm.naming_strategy.underscore
            connection: crawl
            mappings:
                DbBccCrawlBundle: ~

the thing is that I tried that at the start and it failed (the class X not found in...)

If anyone has an explenation, I'll be more than happy to read it.

Thanks anyway

This was the 2nd part of the question, here's the begening : The class 'X' was not found in the chain configured namespaces ... when I try a multiple connection with doctrine