Zend Framework 2 Module for Doctrine MongoDB ODM
Switch branches/tags
Nothing to show
Pull request Compare This branch is 261 commits behind doctrine:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.travis
config
src/DoctrineMongoODMModule
.travis.yml
LICENSE
Module.php
README.md
autoload_classmap.php
autoload_function.php
autoload_register.php
composer.json

README.md

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

Requirements

Zend Framework 2 Application Skeleton (or compatible architecture)

Installation

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

Installation steps

  1. cd my/project/directory

  2. create a composer.json file with following contents:

    {
        "require": {
            "doctrine/DoctrineMongoODMModule": "dev-master"
        }
    }
  3. install composer via curl -s http://getcomposer.org/installer | php (on windows, download http://getcomposer.org/installer 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)

    'DoctrineModule',
    'DoctrineMongoODMModule',
  6. drop vendor/doctrine/DoctrineMongoODMModule/config/module.doctrine_mongodb.local.php.dist into your application's config/autoload directory, rename it to module.doctrine_mongodb.local.php and make the appropriate changes.

  7. 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.

Usage

Command Line

Access the Doctrine command line as following

./vendor/bin/doctrine-module

Service Locator

Access the entity manager using the following di alias:

<?php
$em = $this->getServiceLocator()->get('mongo_dm');

Injection

You can also inject the DocumentManager directly in your controllers/services:

class MyController extends \Zend\Mvc\Controller\ActionController
{
    public function __construct(\Doctrine\ODM\MongoDB\DocumentManager $dm) {
        $this->dm = $dm;
        // now you can use the DocumentManager!
    }
}