PHPackages                             romeoz/rock-mongodb - 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. romeoz/rock-mongodb

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

romeoz/rock-mongodb
===================

Object Document Mapper (ODM) for MongoDB.

0.15.0(10y ago)16682MITPHPPHP &gt;=5.4.0

Since Mar 5Pushed 10y ago1 watchersCompare

[ Source](https://github.com/romeOz/rock-mongodb)[ Packagist](https://packagist.org/packages/romeoz/rock-mongodb)[ RSS](/packages/romeoz-rock-mongodb/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (9)Dependencies (6)Versions (10)Used By (2)

ODM for MongoDB
===============

[](#odm-for-mongodb)

This extension requires MongoDB PHP Extension version 1.5.0 or higher.

Standalone fork by [Yii2 MongoDB 2.0.4](https://github.com/yiisoft/yii2-mongodb).

[![Latest Stable Version](https://camo.githubusercontent.com/372f118360a8d12d73ceec376258ef77b1946697ad7bba3914cc8423f213cde2/68747470733a2f2f706f7365722e707567782e6f72672f726f6d654f7a2f726f636b2d6d6f6e676f64622f762f737461626c652e737667)](https://packagist.org/packages/romeOz/rock-mongodb)[![Total Downloads](https://camo.githubusercontent.com/ed6279db3ff09eadbc0e5b4e4f044dca6a45421d6332dca819ceff0253161a3a/68747470733a2f2f706f7365722e707567782e6f72672f726f6d654f7a2f726f636b2d6d6f6e676f64622f646f776e6c6f6164732e737667)](https://packagist.org/packages/romeOz/rock-mongodb)[![Build Status](https://camo.githubusercontent.com/60796c77375f4a2f63b1c3df932852b4bed59fa9b4efb604357e8235f4ae13f0/68747470733a2f2f7472617669732d63692e6f72672f726f6d654f7a2f726f636b2d6d6f6e676f64622e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/romeOz/rock-mongodb)[![Coverage Status](https://camo.githubusercontent.com/fe2ee6e38d5cbfbcea149c1bc91577f9326b69da1a150409b36b5bfbe22ae959/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f726f6d654f7a2f726f636b2d6d6f6e676f64622f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/r/romeOz/rock-mongodb?branch=master)[![License](https://camo.githubusercontent.com/c807d43bfdc8dddc3e0674f84e34fe66a08d1492c3b56e606c2785e06ffd131c/68747470733a2f2f706f7365722e707567782e6f72672f726f6d654f7a2f726f636b2d6d6f6e676f64622f6c6963656e73652e737667)](https://packagist.org/packages/romeOz/rock-mongodb)

Features
--------

[](#features)

- Query Builder/DBAL/DAO: Querying the database using a simple abstraction layer
- Active Record: The Active Record ODM, retrieving and manipulating records, and defining relations
- Support [MongoGridFS](http://docs.mongodb.org/manual/core/gridfs/)
- Behaviors (SluggableBehavior, TimestampBehavior,...)
- Data Provider
- **Validation and Sanitization rules for AR (Model)**
- **Caching queries**
- **Standalone module/component for [Rock Framework](https://github.com/romeOz/rock)**

> Bolded features are different from [Yii2 MongoDB](https://github.com/yiisoft/yii2-mongodb).

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

[](#installation)

From the Command Line:

```
composer require romeoz/rock-mongodb

```

In your composer.json:

```
{
    "require": {
        "romeoz/rock-mongodb": "*"
    }
}
```

Quick Start
-----------

[](#quick-start)

\####Query Builder

```
$rows = (new \rock\mongodb\Query)
    ->from('users')
    ->all();
```

\####Active Record

```
// find
$users = Users::find()
    ->where(['status' => Users::STATUS_ACTIVE])
    ->orderBy('id')
    ->all();

// insert
$users = new Users();
$users->name = 'Tom';
$users->save();
```

Documentation
-------------

[](#documentation)

- [Basic](https://github.com/yiisoft/yii2/blob/master/extensions/mongodb/README.md): Connecting to a database, basic queries, query builder, and Active Record
- [Data Providers](https://github.com/romeOz/rock-mongodb/blob/master/docs/data-provider.md)

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

[](#requirements)

- **PHP 5.4+**
- For validation rules a model required [Rock Validate](https://github.com/romeOz/rock-validate): `composer require romeoz/rock-validate`
- For sanitization rules a model required [Rock Sanitize](https://github.com/romeOz/rock-sanitize): `composer require romeoz/rock-sanitize`
- For using behaviors a model required [Rock Behaviors](https://github.com/romeOz/rock-behaviors): `composer require romeoz/rock-behaviors`
- For using Data Provider required [Rock Data Provider](https://github.com/romeOz/rock-dataprovider/): `composer require romeoz/rock-dataprovider`
- For caching queries required [Rock Cache](https://github.com/romeOz/rock-behaviors): `composer require romeoz/rock-cache`

> All unbolded dependencies is optional

License
-------

[](#license)

The Object Document Mapping (ODM) for MongoDB is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT).

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Every ~31 days

Recently: every ~6 days

Total

9

Last Release

3845d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/23c5d84a59845d751cb69f5469986579b9312c54c898b366fefdc05baaa80a9c?d=identicon)[romeOz](/maintainers/romeOz)

---

Top Contributors

[![romeOz](https://avatars.githubusercontent.com/u/3135712?v=4)](https://github.com/romeOz "romeOz (97 commits)")

---

Tags

ormdbalmongodbactive-recordquery buildermongodao

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/romeoz-rock-mongodb/health.svg)

```
[![Health](https://phpackages.com/badges/romeoz-rock-mongodb/health.svg)](https://phpackages.com/packages/romeoz-rock-mongodb)
```

###  Alternatives

[mmucklo/queue-bundle

Symfony2/3/4/5 Queue Bundle (for background jobs) supporting Mongo (Doctrine ODM), Mysql (and any Doctrine ORM), RabbitMQ, Beanstalkd, Redis, and ... {write your own}

120839.8k](/packages/mmucklo-queue-bundle)[sokil/php-mongo

PHP Object Document Mapper for MongoDB

239161.5k9](/packages/sokil-php-mongo)[cycle/database

DBAL, schema introspection, migration and pagination

64690.9k31](/packages/cycle-database)[leroy-merlin-br/mongolid

Easy, powerful and ultrafast ODM for PHP and MongoDB.

11234.3k4](/packages/leroy-merlin-br-mongolid)[tommyknocker/pdo-database-class

Framework-agnostic PHP database library with unified API for MySQL, MariaDB, PostgreSQL, SQLite, MSSQL, and Oracle. Query Builder, caching, sharding, window functions, CTEs, JSON, migrations, ActiveRecord, CLI tools, AI-powered analysis. Zero external dependencies.

845.7k](/packages/tommyknocker-pdo-database-class)[denchikby/phalcon-mongodb-odm

Phalcon MongoDB ODM

4212.8k](/packages/denchikby-phalcon-mongodb-odm)

PHPackages © 2026

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