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.
My mistake was that I forgot to add distant bundles/bundles in "vendor" inside my AppKernel
file.
They weren't registered in the registerBundles()
method.
Your bundle should be mapped with correct entity managers you are using for service / command / api in config/packages/doctrine.yaml
(Symfony4) config file.
For example In following doctrine config, BundleName
is mapped with default
entity managers so code using default
entity managers doctrine connection can access and use BundleName
's entities and repositories.
orm:
entity_managers:
default:
mappings:
BundleName:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With