Integrate Doctrine with Zend Framework 1.8 app?

I wrote a Resource Bootstrapper for Doctrine and Zend Framework a few weeks ago and turned it all into a small wrapper framework, cause I think ZF and Doctrine are a great team. You can read the article here: coffeecoders.de/2009/06/using-the-zend-f... It is fully configurable via the Bootstrap resource configurations (example included, too). Unfortunately Doctrine searches for Models in the model folder with the same classname as the filename (which doesn't match the ZF naming scheme) so it was actually not possible to get rid of registering the Doctrine Autoloader.

The resource Loader looks like this:? Php /** * Doctrine model loading bootstrap resource. Options must provide a connection string.

* directory option for model directory is optional (default is . /models). * Further options will be set for the Doctrine manager via setAttribute (e.g. Model_loading).

* @author daff */ class Cuckoo_Application_Resource_Model extends Zend_Application_Resource_ResourceAbstract { public function init() { $manager = Doctrine_Manager::getInstance(); $options = $this->getOptions(); foreach($options as $key => $value) { if($key! = 'connection' && $key! = 'directory') $manager->setAttribute($key, $value); } if(empty($options'connection')) throw new Exception("No database connection string provided!

"); Doctrine_Manager::connection($options'connection'); if(empty($options'directory')) $dir = '. /models'; else $dir = $options'directory'; Doctrine::loadModels(realpath($dir)); return $manager; } }.

I wrote a Resource Bootstrapper for Doctrine and Zend Framework a few weeks ago and turned it all into a small wrapper framework, cause I think ZF and Doctrine are a great team. You can read the article here: coffeecoders.de/2009/06/using-the-zend-f... It is fully configurable via the Bootstrap resource configurations (example included, too). Unfortunately Doctrine searches for Models in the model folder with the same classname as the filename (which doesn't match the ZF naming scheme) so it was actually not possible to get rid of registering the Doctrine Autoloader.

The resource Loader looks like this: getOptions(); foreach($options as $key => $value) { if($key! = 'connection' && $key! = 'directory') $manager->setAttribute($key, $value); } if(empty($options'connection')) throw new Exception("No database connection string provided!"); Doctrine_Manager::connection($options'connection'); if(empty($options'directory')) $dir = '.

/models'; else $dir = $options'directory'; Doctrine::loadModels(realpath($dir)); return $manager; } }.

Thanks. I ended up going with a similar approach. Matthew Lurz has written proposal for a ZendX resource plugin.

He's pasted some initial specifications and code. It's similar to what you have, and solved my problems. – Bryan M.

Jun 11 '09 at 0:01.

weierophinney.net/matthew/archives/220-A... take a look at this post. It gives a detailed explanation, directory structure and how to use autaloading features.

As far as auto-loading is concerned, you can actually use the Doctrine loader with the new Zend_Loader_Autoloader stack quite easily. Take a look at this page, especially where it mentions the pushAutoloader() method. Here's the basic run down, though: $autoloader = Zend_Loader_Autoloader->getInstance(); $autoloader->pushAutoloader(array('Doctrine', 'autoload'), 'Doctrine'); This will use Doctrine's own autoloader for only classes that begin with Doctrine, if they are not already found by other autoloaders in the stack.

Hope this helps a bit.

I'm interested in using Doctrine as an ORM for a new Zend Framework app I'm writing. I'm trying to figure out the best way to integrate it as straightforward as possible. Every example I find is different, and a lot of them pre-date the new autoloading features in ZF 1.8. None of them have worked for me yet.

Does anyone have a good way to do this? I'm inclined to want to place it in my bootstrap file, but some people suggest making a Zend_Application_Resource plugin. The hard part seems to be getting the load paths working correctly for both the Doctrine namespace and the model classes which by default don't follow the Zend auto-loading convention.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions