Symfony error The class XXX was not found in the chain configured namespaces XXX

后端 未结 3 656
栀梦
栀梦 2020-11-29 09:59

There are some other questions on this subject already, but none of them were really helpful. I am new to Symfony, so it\'s pretty hard to get my head around it.

I

3条回答
  •  生来不讨喜
    2020-11-29 10:34

    By default, the auto_mapping feature looks for entities under the Entity namespace, so given that your entity is not there, Doctrine does not know anything about it.

    You need to put your entity under the Entity namespace or configure Doctrine by hand to add your custom entity namespace. This way you lose the auto_mapping feature, so you would need to register every bundle manually:

    orm:
        auto_generate_proxy_classes: %kernel.debug%
        entity_managers:
            default:
                mappings:
                    MyBundle:
                        type: annotation
                    custom_mapping:
                        type: annotation
                        prefix: Client\IntranetBundle\LDAP\
                        dir: "%kernel.root_dir%/src/Client/IntranetBundle/LDAP/"
                        is_bundle: false
    

    As you can see, it's better to put everything under the Entity namespace in your bundle and let Doctrine do the hard work.

提交回复
热议问题