Is there a way to modify the entity mapping configuration for doctrine outside the config file? Is there a way to modify the entity mapping configuration for doctrine outside the config file? symfony symfony

Is there a way to modify the entity mapping configuration for doctrine outside the config file?


To answer myself:

the most simple way is to adjust the autoloading, there is no need to modify the settings. In Symfony's standard distribution in autoload.php you have to add another location to the registerNamespace-method:

$loader->registerNamespaces(array(    [...]    'Foo' => array(__DIR__.'/../src/dirA', __DIR__.'/../src/dirB')));

Doctrine will then look for entities in the "Foo" namespace first in dirA and then in dirB if not found.


You can include other configuration files using imports

# yamlimports:    - { resource: entities.yml }<!-- xml --><imports>    <import resource="enditites.xml" /></imports>// PHP$loader->import('entities.php');

You don't even have to stick to a single file type. It's possible to import an xml configuration file to a yaml file, for example.