PHPackages                             brunohulk/yii2-mongodb-doctrine - 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. [Database &amp; ORM](/categories/database)
4. /
5. brunohulk/yii2-mongodb-doctrine

ActiveLibrary[Database &amp; ORM](/categories/database)

brunohulk/yii2-mongodb-doctrine
===============================

Doctrine MongoDB ODM extension for Yii2

1.1.0(8y ago)14.9k↓45%MITPHP

Since Oct 8Pushed 8y ago1 watchersCompare

[ Source](https://github.com/brunohulk/yii2-mongodb-doctrine)[ Packagist](https://packagist.org/packages/brunohulk/yii2-mongodb-doctrine)[ RSS](/packages/brunohulk-yii2-mongodb-doctrine/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (5)Versions (4)Used By (0)

Yii2 extension for using MongoDB and Doctrine
=============================================

[](#yii2-extension-for-using-mongodb-and-doctrine)

[![Latest Stable Version](https://camo.githubusercontent.com/09798b2399622a710bf8579dc25a5eff17921408b5c5ba4673f3a79b8708bd60/68747470733a2f2f706f7365722e707567782e6f72672f6272756e6f68756c6b2f796969322d6d6f6e676f64622d646f637472696e652f762f737461626c65)](https://packagist.org/packages/brunohulk/yii2-mongodb-doctrine)[![Downloads](https://camo.githubusercontent.com/75cf1e42f7f3940cd2f6feed5fa75693f6e3a88fe4868dfe7ac57256c07aac86/68747470733a2f2f706f7365722e707567782e6f72672f6272756e6f68756c6b2f796969322d6d6f6e676f64622d646f637472696e652f646f776e6c6f616473)](https://packagist.org/packages/brunohulk/yii2-mongodb-doctrine)[![License](https://camo.githubusercontent.com/780d436c3f43d4c99d587632b0575f580081366058a29ad9b16e248c941fe303/68747470733a2f2f706f7365722e707567782e6f72672f6272756e6f68756c6b2f796969322d6d6f6e676f64622d646f637472696e652f6c6963656e7365)](https://packagist.org/packages/brunohulk/yii2-mongodb-doctrine)

About
-----

[](#about)

This component was created with the purpose of allowing us to use all benefits of the Doctrine in Yii2 using the MongoDB ODM version. There are others solutions which use MongoDB and the active record pattern from Yii, but the vast Doctrine documentation and its better way to deal with embedded documents made its case.

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

[](#installation)

Require the library with Composer:

```
composer require brunohulk/yii2-mongodb-doctrine

```

Then, to activate the component, you have to add the follow entry inside the web.php file replacing the default database params by your customise data:

```
'doctrineOdm' => [
    'class' => 'brunohulk\Yii2MongodbOdm\DoctrineODM',
    'dsn' => 'mongodb://mongodb:27017', #DSN string connection
    'dbname' => 'database_name'  #Database name,
    'documentsDir' => __DIR__ . '/../../documents/', # Directory which stores your mapped collections
    'runtimeDir' =>  __DIR__ . '/../../runtime/' # The Yii2 runtime dir or other directory to store the Doctrine extra files
]
```

Usage
-----

[](#usage)

To start using the Document manager all you have to do is call the method below in any place you desire, like a controller:

```
class User extends Controller
{
    private $documentManager;

    public function init()
    {
        $this->documentManager = Yii::$app->doctrineOdm->getDocumentManager();
    }

    public function actionCreate()
    {
        $user = new User;
        $user->name = "Bruno";

        $this->documentManager->persist($user);
        $this->documentManager->flush();

    }
```

For the last step, is necessary to create a `documents` folder within the `common` directory in your Yii project, all the documents mapped must be there, the following example is related to previous doc block.

```
/**
 * @ODM\Document(collection="user")
 */
class User
{
    /**
     * @ODM\Id
     */
    public $id;

    /**
     * @ODM\Field(name="name", type="string")
     */
    public $name;

}
```

Special thanks for [David Rocha](https://github.com/davidasrocha)

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity65

Established project with proven stability

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

Every ~1 days

Total

3

Last Release

3181d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/72eb835cf399dc84eb1226648c607190f09da828c5118670d033ee7e78ca19ea?d=identicon)[borgesbruno](/maintainers/borgesbruno)

### Embed Badge

![Health badge](/badges/brunohulk-yii2-mongodb-doctrine/health.svg)

```
[![Health](https://phpackages.com/badges/brunohulk-yii2-mongodb-doctrine/health.svg)](https://phpackages.com/packages/brunohulk-yii2-mongodb-doctrine)
```

###  Alternatives

[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k8.0M88](/packages/mongodb-laravel-mongodb)[rcsofttech/audit-trail-bundle

Enterprise-grade, high-performance Symfony audit trail bundle. Automatically track Doctrine entity changes with split-phase architecture, multiple transports (HTTP, Queue, Doctrine), and sensitive data masking.

1155.2k](/packages/rcsofttech-audit-trail-bundle)[kimai/kimai

Kimai - Time Tracking

4.7k8.7k1](/packages/kimai-kimai)[2lenet/crudit-bundle

The easy like Crud'it Bundle.

1615.6k12](/packages/2lenet-crudit-bundle)

PHPackages © 2026

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