PHPackages                             monga/monga - 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. monga/monga

Abandoned → [php-loep/monga](/?search=php-loep%2Fmonga)Library[Database &amp; ORM](/categories/database)

monga/monga
===========

MongoDB Abstraction Layer

0.2.4(12y ago)695.7k81MITPHPPHP &gt;=5.3.3

Since Nov 15Pushed 12y ago7 watchersCompare

[ Source](https://github.com/frankdejonge/Monga)[ Packagist](https://packagist.org/packages/monga/monga)[ Docs](https://github.com/FrenkyNet/Monga)[ RSS](/packages/monga-monga/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (9)Used By (1)

Monga [![Build Status](https://camo.githubusercontent.com/4488572fee96e46eedd5d083a432dcbb81ebbdff66ba7f84904e94ea70652ffb/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f4672656e6b794e65742f4d6f6e67612e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/FrenkyNet/Monga)
================================================================================================================================================================================================================================================================================================

[](#monga-)

A simple and swift MongoDB abstraction layer for PHP5.3+

[Find Monga on Packagist/Composer](https://packagist.org/packages/monga/monga)

What's this all about?
----------------------

[](#whats-this-all-about)

- An easy API to get connections, databases and collection.
- A filter builder that doesn't make your mind go nuts.
- All sorts of handy update functions.
- An abstraction for sorting single results.
- GridFS support for a Mongo filesystem.
- Easy aggregation and distinct values.

Vision
------

[](#vision)

Monga was created with the acknowledgement of the MongoDB PHP package already being pretty awesome. That's why in a lot of cases Monga is just a simple wrapper around the MongoDB classes. It provides some helpers and helps you set up queries using a query builder. Which you cal also choose not to use! All will still works accordingly. During the development a lot of planning has gone into creating a nice streamlined API that closely follows the MongoDB base classes, while complementing existing query builder for SQL-like database.

Examples
--------

[](#examples)

```
// Get a connection
$connection = Monga::connection($dsn, $connectionOptions);

// Get the database
$database = $connection->database('db_name');

// Drop the database
$database->drop();

// Get a collection
$collection = $database->collection('collection_name');

// Drop the collection
$collection->drop();

// Truncate the collection
$collection->truncate();

// Insert some values into the collection
$insertIds = $collection->insert(array(
	array(
		'name' => 'John',
		'surname' => 'Doe',
		'nick' => 'The Unknown Man',
		'age' => 20,
	),
	array(
		'name' => 'Frank',
		'surname' => 'de Jonge',
		'nick' => 'Unknown',
		'nik' => 'No Man',
		'age' => 23,
	),
));

// Update a collection
$collection->update(function($query){
	$query->increment('age')
		->remove('nik')
		->set('nick', 'FrenkyNet');
});

// Find Frank
$frank = $collection->findOne(function($query){
	$query->where('name', 'Frank')
		->whereLike('surname', '%e Jo%');
});

// Or find him using normal array syntax
$frank = $collection->find(array('name' => 'Frank', 'surname' => new MongoRegex('/e Jo/imxsu')));

$frank['age']++;

$collection->save($frank);

// Also supports nested queries
$users = $collection->find(function($query){
	$query->where(function($query){
		$query->where('name', 'Josh')
			->orWhere('surname', 'Doe');
	})->orWhere(function(){
		$query->where('name', 'Frank')
			->where('surname', 'de Jonge');
	});
});

// get the users as an array
$arr = $users->toArray();
```

Aggregation
-----------

[](#aggregation)

A big part of the newly released MongoDB pecl package is aggregation support. Which is super easy to do with Monga:

```
$collection->aggregate(function($a){
	$a->project(array(
		'name' => 1,
		'surname' => -1,
		'tags' => 1,
	))->unwind('tags');

	// But also more advanced groups/projections
	$a->project(function($p){
		$p->select('field')
			->select('scores')
			->exclude('other_field');
	})->group(function($g){
		$g->by(array('$name', '$surname'))
			->sum('scores');
	});
});
```

If you need any help, come find me in the IRC channels (#fuelphp/#cabinet/#mongodb by the nick of: FrenkyNet)

Enjoy!

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity32

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 96.2% 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 ~52 days

Recently: every ~91 days

Total

8

Last Release

4559d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/534693?v=4)[Frank de Jonge](/maintainers/frankdejonge)[@frankdejonge](https://github.com/frankdejonge)

---

Top Contributors

[![frankdejonge](https://avatars.githubusercontent.com/u/534693?v=4)](https://github.com/frankdejonge "frankdejonge (75 commits)")[![dragoonis](https://avatars.githubusercontent.com/u/146321?v=4)](https://github.com/dragoonis "dragoonis (1 commits)")[![musaulker](https://avatars.githubusercontent.com/u/195523?v=4)](https://github.com/musaulker "musaulker (1 commits)")[![pborreli](https://avatars.githubusercontent.com/u/77759?v=4)](https://github.com/pborreli "pborreli (1 commits)")

---

Tags

mongodb

### Embed Badge

![Health badge](/badges/monga-monga/health.svg)

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

###  Alternatives

[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k7.2M71](/packages/mongodb-laravel-mongodb)[mongodb/mongodb

MongoDB driver library

1.6k64.0M546](/packages/mongodb-mongodb)[phpfastcache/phpfastcache

PHP Abstract Cache Class - Reduce your database call using cache system. Phpfastcache handles a lot of drivers such as Apc(u), Cassandra, CouchBase, Couchdb, Dynamodb, Firestore, Mongodb, Files, (P)redis, Leveldb, Memcache(d), Ravendb, Ssdb, Sqlite, Wincache, Xcache, Zend Data Cache.

2.4k5.0M130](/packages/phpfastcache-phpfastcache)[doctrine/mongodb-odm

PHP Doctrine MongoDB Object Document Mapper (ODM) provides transparent persistence for PHP objects to MongoDB.

1.1k23.3M302](/packages/doctrine-mongodb-odm)[friendsofsymfony/elastica-bundle

Elasticsearch PHP integration for your Symfony project using Elastica

1.3k17.2M47](/packages/friendsofsymfony-elastica-bundle)[doctrine/mongodb-odm-bundle

Symfony Doctrine MongoDB Bundle

38418.7M195](/packages/doctrine-mongodb-odm-bundle)

PHPackages © 2026

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