Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Zend Framework with modular structure + Doctrine 2

I use Zend Framework with modules for my applications and I am interested in integrating Doctrine 2 in the same fashion:

A module contains:

  • controllers
  • models
  • views
  • helpers

The problem with Doctrine 2 is that it requires to have an entity directory along with a proxy directory. I want the entities directory to be the models directory from my modular structure and based on my research I haven't found a solution.

Currently, with a default module the metadata implementation looks like this:

$config->setMetadataDriverImpl($config->newDefaultAnnotationDriver(APPLICATION_PATH . '/modules/default/models'));

If I want to add a new module, let's say "cms" I have no way of managing the models there with Doctrine.

Is there anyone that has a solution for the problem ?

like image 511
bedeabza Avatar asked Dec 09 '10 12:12

bedeabza


1 Answers

After some hours of work I came up with the correct solution. To be noted that the newDefaultAnnotationDriver, setProxyDir and setProxyNamespace methods of Doctrine's \ORM\Configuration class can receive also array parameters.

This being said, you need to pass arrays with model paths for every module and it will work

like image 160
bedeabza Avatar answered Nov 03 '22 05:11

bedeabza