I'm working with Zend 2 from a few days, and I have a little trouble. We are using doctrine, and trying to generate the data base schema from the entities. I specify in each module where doctrine should find the entities using module.config.php file of each module. Currently I have 2 modules with 2 diferent module.config files and these are the lines where I specify the paths where Doctrine should find the entities:
module.config.php (MailTemplates (Module))
'doctrine' => array(
'driver' => array(
'application_entities' => array(
'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
'cache' => 'array',
'paths' => (__DIR__ . '/../src/MailTemplates/Model')
),
'orm_default' => array(
'drivers' => array(
'MailTemplates\Model' => 'application_entities'
),
),
),
),
and module.config.php (Application (Module))
'doctrine' => array(
'driver' => array(
'application_entities' => array(
'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
'cache' => 'array',
'paths' => (__DIR__ . '/../src/Application/Entity')
),
'orm_default' => array(
'drivers' => array(
'Application\Entity' => 'application_entities'
),
),
),
),
);
When I execute the command to generate the schema from the entities (./vendor/bin/doctrine-module orm:schema-tool:create) it only creates the MailTemplate tables, and ignore the Application module ones. If I comment the lines of the module.config.php of MailTemplate module, and execute the command again, I can se that tables from the Application Module entity have been created succesfully. So I suppose that somehow the info from the 2 module.config files is being overwritten.
I need to generate the DB shema from diferent entities from different modules and I don't know how.
Thanks!!
The reason for this is that you are setting the same name to the drivers. Although zend merge the configurations, it will override configurations with same names.
module.config.php (MailTemplates (Module))
[...]
'drivers' => array(
'MailTemplates\Model' => 'application_entities' <-- rename this
)
[..]
module.config.php (Application (Module))
[...]
'drivers' => array(
'Application\Entity' => 'application_entities'
)
[..]