The DoctrineMongoODMModule integrates Doctrine 2 MongoDB ODM with Zend Framework 2 quickly and easily. The following features are intended to work out of the box:
- MongoDB support
- Multiple document managers
- Multiple connections
- Support for using existing
Mongo
connections
Zend Framework 2 Application Skeleton (or compatible architecture)
Installation of this module uses composer. For composer documentation, please refer to getcomposer.org.
-
cd my/project/directory
-
create a
composer.json
file with following contents:{ "require": { "doctrine/doctrine-mongo-odm-module": "dev-master" } }
-
install composer via
curl -s http://getcomposer.org/installer | php
(on windows, download http://getcomposer.org/installer and execute it with PHP) -
run
php composer.phar install
-
open
my/project/directory/configs/application.config.php
and add following keys to yourmodules
(in this order)'DoctrineModule', 'DoctrineMongoODMModule',
-
copy
vendor/doctrine/doctrine-mongo-odm-module/config/module.doctrine-mongo-odm.local.php.dist
into your application'sconfig/autoload
directory, rename it tomodule.doctrine-mongo-odm.local.php
and make the appropriate changes. With this config file you can configure your mongo connection, add extra annotations to register, add subscribers to the event manager, add filters to the filter collection, and drivers to the driver chain. -
create directory
my/project/directory/data/DoctrineMongoODMModule/Proxy
and
my/project/directory/data/DoctrineMongoODMModule/Hydrators
and make sure your application has write access to it.
Access the Doctrine command line as following
./vendor/bin/doctrine-module
Access the entity manager using the following service manager alias:
<?php
$dm = $this->getServiceLocator()->get('doctrine.documentmanager.odm_default');