symfony/symfony — Issue #3203: Bug searching entities in a non default path
Author: sibok
Created: 2012-01-28 09:45:32+00:00
State: open

Don't know if the bug is cause by the way of handling config.yml or a bug in Doctrine2 annotation markup language.

I've placed entities inside myVendor\myBundleBundle\Entity namespace which are properly handled by mysql entity manager, and also placed entitites inside myVendor\myBundleBundle\View which are readonly entities which should be handled by form entity manager.

I've configured my bundle entity manager in the following way:
doctrine:
dbal:
default_connection: mysql
connections:
mysql:
user: %mysql_database_user%
password: %mysql_database_password%
host: %mysql_database_host%
dbname: %mysql_database_name%
charset: UTF8
driver: %mysql_database_driver%
logging: %kernel.debug%
form:
port: %form_database_port%
user: %form_database_user%
password: %form_database_password%
host: %form_database_host%
dbname: %form_database_name%
charset: UTF8
driver: %form_database_driver%
logging: %kernel.debug%
orm:
auto_generate_proxy_classes: %kernel.debug%
#auto_mapping: true
default_entity_manager: default
entity_managers:
default:
connection: mysql
mappings:
myVendormyBundleBundle: ~
form:
connection: formacions
mappings:
myVendormyBundleBundle: { type: annotation, dir: View/Entity }

and doctrine is looking for entities in the specified directory but it is only able to find them when the namespace contains Entity word. So when namespace is myVendor\myBundleBundle\View; the command ./symfony2 doctrine:mapping:info --em=for complains saying:

[LogicException]
You do not have any mapped Doctrine ORM entities for any of your bundles. Create a class inside the Entity namespace of any of your bundles and provide mapping information for it with Annotations directly in the classes doc blocks or with XML/YAML in your bundles Resources/config/doctrine/ directory

When i change the namespace to myVendor\myBundleBundle\Entity; Although entities are placed inside View\ it seems to work fine:

./symfony2 doctrine:mapping:info --em=for
Found 1 entities mapped in entity manager for:
[OK] myVendor\myBundleBundle\Entity\myEntity