It is very easy to write a Zend Bootstrap Resource .
Here is one of them:
<?php namespace Cob\Application\Resource; use Doctrine\Common\Annotations\AnnotationReader, Doctrine\ODM\MongoDB\DocumentManager, Doctrine\MongoDB\Connection, Doctrine\ODM\MongoDB\Configuration, Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver, Doctrine\Common\EventManager; class Mongo extends \Zend_Application_Resource_ResourceAbstract { public function init() { $options = $this->getOptions() + array( 'defaultDB' => 'my_database', 'proxyDir' => APPLICATION_PATH . '/domain/Proxies', 'proxyNamespace' => 'Application\Proxies', 'hydratorDir' => APPLICATION_PATH . '/domain/Hydrators', 'hydratorNamespace' => 'Application\Hydrators' ); $config = new Configuration(); $config->setProxyDir($options['proxyDir']); $config->setProxyNamespace($options['proxyNamespace']); $config->setHydratorDir($options['hydratorDir']); $config->setHydratorNamespace($options['hydratorNamespace']); $config->setDefaultDB($options['defaultDB']); $reader = new AnnotationReader(); $reader->setDefaultAnnotationNamespace('Doctrine\ODM\MongoDB\Mapping\\'); $config->setMetadataDriverImpl(new AnnotationDriver($reader, $this->getDocumentPaths())); $evm = new EventManager(); $evm->addEventSubscriber(new SlugSubscriber()); return DocumentManager::create(new Connection(), $config, $evm); } public function getDocumentPaths() { $paths = array(); foreach(new \DirectoryIterator(APPLICATION_PATH . '/modules') as $module){ $path = $module->getPathname() . '/src/Domain/Document'; if((!$module->isDir() || $module->isDot()) || !is_dir($path)){ continue; } $paths[] = $path; } if(!count($paths)){ throw new \Exception("No document paths found"); } return $paths; } }
Although you will have to update the getDocumentPaths () method to match the structure of your application directory.
Cobby source share