PHPackages                             helderjs/doctrine-mongo-odm - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. helderjs/doctrine-mongo-odm

ActiveLibrary[HTTP &amp; Networking](/categories/http)

helderjs/doctrine-mongo-odm
===========================

DoctrineMongoODM component for (Micro-)Framework

v1.0.0(8y ago)918.3k5[2 issues](https://github.com/helderjs/doctrine-mongo-odm/issues)[1 PRs](https://github.com/helderjs/doctrine-mongo-odm/pulls)MITPHPPHP ~5.6 || &gt;=7.0

Since May 7Pushed 8y ago2 watchersCompare

[ Source](https://github.com/helderjs/doctrine-mongo-odm)[ Packagist](https://packagist.org/packages/helderjs/doctrine-mongo-odm)[ RSS](/packages/helderjs-doctrine-mongo-odm/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (5)Versions (2)Used By (0)

DoctrineMongoODM Component
==========================

[](#doctrinemongoodm-component)

[![Build Status](https://camo.githubusercontent.com/600e034849835f75ebc788cfbaa8b94a465de57d0daeb365c60ad30b54a8e2f0/68747470733a2f2f7472617669732d63692e6f72672f68656c6465726a732f646f637472696e652d6d6f6e676f2d6f646d2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/helderjs/doctrine-mongo-odm)

It's a component based on [DoctrineMongoODMModule](https://github.com/doctrine/DoctrineMongoODMModule) that provides [DoctrineMongoDbODM](http://docs.doctrine-project.org/projects/doctrine-mongodb-odm) integration for several (Micro-)frameworks. The goal is be light and easy to configure, for that the library rely just on the [PSR-11](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-11-container.md) and [MongoBD ODM](http://docs.doctrine-project.org/projects/doctrine-mongodb-odm/en/latest/).

Requirements
------------

[](#requirements)

- PHP 5.6+
- [ext-mongo](https://pecl.php.net/package/mongodb) (if php version &lt; 7)
- [mongo-php-adapter](https://github.com/alcaeus/mongo-php-adapter) (if php version &gt;= 7)

ps.: if using [mongo-php-adapter](https://github.com/alcaeus/mongo-php-adapter) you should add and install it first in you project. After this the library will declare to composer that it provides the ext-mongo.

We recommend using a dependency injection container, and typehint against [PSR-11](https://github.com/php-fig/container).

Installation
------------

[](#installation)

Install this library using composer:

```
$ composer require helderjs/doctrine-mongo-odm
```

Configuration
-------------

[](#configuration)

How to create the config file (What you should/can put in the config).

```
return [
    'config' => [
        ...
        'doctrine' => [
            'default' => 'odm_default',
            'connection' => [
                'odm_default' => [
                    'server'           => 'localhost',
                    'port'             => '27017',
                    'user'             => 'myUser',
                    'password'         => 'myHardPassword',
                    'dbname'           => 'dbName',
                    'options'          => []
                ],
                'odm_secondary' => [
                    'connectionString' => 'mongodb://username:password@server2:27017/mydb',
                    'options'          => []
                ],
            ],
            'driver' => [
                'odm_default' => [
                    \Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver::class => [
                        'documents_dir' => ['./src/myApp/Documents']
                    ],
                    \Doctrine\ODM\MongoDB\Mapping\Driver\XmlDriver::class => [
                        'simplified' => false,
                        'xml_dir' => [
                            '/path/to/files1',
                            '/path/to/files2',
                        ]
                     ],
                    \Doctrine\ODM\MongoDB\Mapping\Driver\YamlDriver::class => [
                        'simplified' => false,
                        'yml_dir' => [
                            '/path/to/files1',
                            '/path/to/files2',
                        ]
                    ],
                    \Doctrine\ODM\MongoDB\Mapping\Driver\MappingDriverChain::class => [
                        'Driver\Annotation' => \Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver::class,
                        'Driver\Xml' => \Doctrine\ODM\MongoDB\Mapping\Driver\XmlDriver::class,
                        'Driver\Yaml' => \Doctrine\ODM\MongoDB\Mapping\Driver\YamlDriver::class,
                    ],
                ],
            ],
            'configuration' => [
                'odm_default' => [
                    'metadata_cache'     => \Doctrine\Common\Cache\ArrayCache::class, // optional
                    'driver'             => \Doctrine\ODM\MongoDB\Mapping\Driver\MappingDriverChain::class,
                    'generate_proxies'   => true,
                    'proxy_dir'          => 'data/DoctrineMongoODMModule/Proxy',
                    'proxy_namespace'    => 'DoctrineMongoODMModule\Proxy',
                    'generate_hydrators' => true,
                    'hydrator_dir'       => 'data/DoctrineMongoODMModule/Hydrator',
                    'hydrator_namespace' => 'DoctrineMongoODMModule\Hydrator',
                    'default_db'         => 'MyDBName',
                    'filters'            => [], // custom filters (optional)
                    'types'              => [], // custom types (optional)
                    'retry_connect'      => 0 // optional
                    'retry_query'        => 0 // optional
                    'logger'             => \MyLogger::calss \\ Logger implementation (optional)
                    'classMetadataFactoryName' => 'stdClass' \\ optional
                ]
            ],
            'documentmanager' => [
                'odm_default' => [
                    'connection'    => \Doctrine\ODM\MongoDB\Connection::class,
                    'configuration' => \Doctrine\ODM\MongoDB\Configuration::class,
                    'eventmanager'  => \Doctrine\ODM\MongoDB\EventManager::class, \\ optional
                ],
                'odm_secondary' => [
                    'connection'    => 'doctrine.connection.secondary',
                    'configuration' => \Doctrine\ODM\MongoDB\Configuration::class,
                    'eventmanager'  => 'doctrine.eventmanager.secondary', \\ optional
                ]
            ],
            'eventmanager' => [ \\ optional
                'odm_default' => [
                    'subscribers' => [
                        \MySubscriberImpl1::class,
                    ],
                ],
                'odm_secondary' => [
                    'subscribers' => [
                        new \MySubscriberImpl2(),
                    ],
                ],
            ],
        ],
        ...
    ],
];
```

Configuring DI at Zend Expressive

```
...
'dependencies' => [
    'invokables' => [
        \Doctrine\Common\Cache\ArrayCache::class => \Doctrine\Common\Cache\ArrayCache::class,
        \MyLogger::class  => \MyLogger::class,
    ],
    'factories' => [
        \Doctrine\ODM\MongoDB\Configuration::class   => ConfigurationFactory::class,
        \Doctrine\ODM\MongoDB\Connection::class      => ConnectionFactory::class,
        \Doctrine\ODM\MongoDB\EventManager::class    => EventManagerFactory::class,
        \Doctrine\ODM\MongoDB\DocumentManager::class => DocumentManagerFactory::class,
        'doctrine.connection.secondary'              => new ConnectionFactory('odm_secondary'),
        'doctrine.eventmanager.secondary'            => new EventManagerFactory('odm_secondary'),
        'doctrine.documentmandager.secondary'        => new DocumentManagerFactory('odm_secondary'),
        \Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver::class   => \Helderjs\Component\DoctrineMongoODM\AnnotationDriverFactory::class,
        \Doctrine\ODM\MongoDB\Mapping\Driver\XmlDriver::class          => \Helderjs\Component\DoctrineMongoODM\AnnotationDriverFactory::class,
        \Doctrine\ODM\MongoDB\Mapping\Driver\YamlDriver::class         => \Helderjs\Component\DoctrineMongoODM\AnnotationDriverFactory::class,
        \Doctrine\ODM\MongoDB\Mapping\Driver\MappingDriverChain::class => \Helderjs\Component\DoctrineMongoODM\AnnotationDriverFactory::class,
    ],
 ],
 ...
```

SlimPHP

```
$container['doctrine-connection'] = function ($container) {
    $factory = new ConnectionFactory();

    return $factory($container);
};

$container['doctrine-configuration'] = function ($container) {
    $factory = new ConfigurationFactory();

    return $factory($container);
};

$container['doctrine-eventmanager'] = function ($container) {
    $factory = new EventManagerFactory();

    return $factory($container);
};

$container['doctrine-driver'] = function ($container) {
    $factory = new MappingDriverChainFactory();

    return $factory($container);
};
```

Goals
-----

[](#goals)

- Improve unit tests
- Improve documentation
- Implementing real examples
- ?introduce new features?

If you want to help: install, test it, report an issue, fork, open a pull request

License
-------

[](#license)

The MIT License (MIT). Please see [License File](https://github.com/helderjs/doctrine-mongo-odm/blob/master/LICENSE) for more information.

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance16

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 85.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2928d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f62830edd064834f5338a2063802742e9507eea6ba6d2b92b54398fdfbe6a08e?d=identicon)[helderjs](/maintainers/helderjs)

---

Top Contributors

[![helderjs](https://avatars.githubusercontent.com/u/106690?v=4)](https://github.com/helderjs "helderjs (36 commits)")[![vinaocruz](https://avatars.githubusercontent.com/u/2317837?v=4)](https://github.com/vinaocruz "vinaocruz (5 commits)")[![matwright](https://avatars.githubusercontent.com/u/4989280?v=4)](https://github.com/matwright "matwright (1 commits)")

---

Tags

httppsrpsr-7middlewaredoctrineodmmongodbexpressive

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/helderjs-doctrine-mongo-odm/health.svg)

```
[![Health](https://phpackages.com/badges/helderjs-doctrine-mongo-odm/health.svg)](https://phpackages.com/packages/helderjs-doctrine-mongo-odm)
```

###  Alternatives

[mezzio/mezzio

PSR-15 Middleware Microframework

3883.6M97](/packages/mezzio-mezzio)[mezzio/mezzio-router

Router subcomponent for Mezzio

265.0M61](/packages/mezzio-mezzio-router)[mezzio/mezzio-helpers

Helper/Utility classes for Mezzio

134.3M67](/packages/mezzio-mezzio-helpers)[mezzio/mezzio-fastroute

FastRoute integration for Mezzio

162.7M52](/packages/mezzio-mezzio-fastroute)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
