Skip to content
Zend Framework 2 Module for Doctrine MongoDB ODM
Latest commit d17194c Mar 28, 2016 @gianarb gianarb Merge pull request #161 from alcaeus/php-7-tests
Add PHP 7 to the build matrix
Failed to load latest commit information.
config allow adding custom types via module config Apr 29, 2015
doc Merge pull request #109 from romankonz/master Nov 29, 2014
src/DoctrineMongoODMModule Fix pagination count with eager cursors Jan 30, 2016
tests Fixed Zend\Mvc 2.7 compatibility Mar 22, 2016
view/zend-developer-tools/toolbar Fix Github fork link Jan 16, 2014
.gitignore removed files for old test setup Nov 29, 2014
.travis.yml Add PHP 7 to the build matrix Mar 28, 2016 Update changelog Mar 22, 2016
Module.php Added namespace autoloading for non-Composer users. Aug 2, 2012 Update Mar 13, 2014

Doctrine MongoDB ODM Module for Zend Framework 2

Master: Build Status

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
  • Doctrine Cli support


Zend Framework 2 Application Skeleton (or compatible architecture)


Installation of this module uses composer. For composer documentation, please refer to

Installation steps

  1. cd my/project/directory
  2. create a composer.json file with following contents:

         "minimum-stability": "alpha",
         "require": {
             "doctrine/doctrine-mongo-odm-module": "dev-master"
  3. install composer via curl -s | php (on windows, download and execute it with PHP)
  4. run php composer.phar install
  5. open my/project/directory/configs/application.config.php and add following keys to your modules (in this order)

  6. copy vendor/doctrine/doctrine-mongo-odm-module/config/module.doctrine-mongo-odm.local.php.dist into your application's config/autoload directory, rename it to module.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.

  7. create directory my/project/directory/data/DoctrineMongoODMModule/Proxy and my/project/directory/data/DoctrineMongoODMModule/Hydrator and make sure your application has write access to it.


Command Line

Access the Doctrine command line as following


Service Locator

Access the document manager using the following service manager alias:

$dm = $this->getServiceLocator()->get('doctrine.documentmanager.odm_default');


Connection section

Either server or connectionString option has to be set.

Name Default Description
server 'localhost' IP of mongod instance
port 27017 mongod port
connectionString null If the connection string is specified, it will overwrite other connection options (server,port,user,password,dbname). Still, the connection will respect the settings passed in options array.
user null If set, the client will try to authenticate with given username and password
password null If set, the client will try to authenticate with given username and password
dbname null If dbname is not specified, "admin" will be used for authentication. Also, specifiing dbname affecs the defaultDB configuration option, if that's not specified explicitly.
options array() Array with connection options. More detailed description in
Something went wrong with that request. Please try again.