Symfony doctrine auto_mapping Unrecognized

孤者浪人 提交于 2019-12-29 05:46:46

问题


I have added SonataUserBundle and it is giving error

config.yml

doctrine: 
    orm:
        auto_generate_proxy_classes: "%kernel.debug%"
        naming_strategy: doctrine.orm.naming_strategy.underscore
        auto_mapping: true

        entity_managers:
            default:
                mappings:
                    ApplicationSonataUserBundle: ~
                    SonataUserBundle: ~

error

Unrecognized options "naming_strategy, auto_mapping, dql" under "doctrine.orm"


回答1:


You are mixing shortened and full configuration.

If you just want to use the default entity manager then you can place everything under the orm key (the shortened config). This will be remapped so that it is under doctrine.orm.entity_managers.default by the bundle extension.

If, however, you want to chaneg the name of the entity manager or use multiples then you would need to use the full configuration specifying each entity manager.

Shortened Config

doctrine: 
    orm:
        auto_generate_proxy_classes: "%kernel.debug%"
        naming_strategy: doctrine.orm.naming_strategy.underscore
        auto_mapping: true
        mappings:
            ApplicationSonataUserBundle: ~
            SonataUserBundle: ~

Full Config

doctrine: 
    orm:
        auto_generate_proxy_classes: "%kernel.debug%"
        entity_managers:
            default:
                naming_strategy: doctrine.orm.naming_strategy.underscore
                auto_mapping: true
                mappings:
                    ApplicationSonataUserBundle: ~
                    SonataUserBundle: ~



回答2:


Do you think it is necessary to configure the mappings manually if you set auto_mapping to true?

Doctrine's auto_mapping feature loads annotation configuration from the Entity/ directory of each bundle and looks for other formats (e.g. YAML, XML) in the Resources/config/doctrine directory.

http://symfony.com/doc/current/reference/configuration/doctrine.html#custom-mapping-entities-in-a-bundle



来源:https://stackoverflow.com/questions/37634625/symfony-doctrine-auto-mapping-unrecognized

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!