PHPackages                             fahmiardi/mongoqb - 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. fahmiardi/mongoqb

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

fahmiardi/mongoqb
=================

Mongo Query Builder

1.3.3(11y ago)13651MITPHPPHP &gt;=5.3.0

Since Nov 4Pushed 11y ago1 watchersCompare

[ Source](https://github.com/fahmiardi/MongoQB)[ Packagist](https://packagist.org/packages/fahmiardi/mongoqb)[ Docs](https://github.com/fahmiardi/MongoQB)[ RSS](/packages/fahmiardi-mongoqb/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependencies (1)Versions (12)Used By (0)

A PHP MongoDB query builder library
===================================

[](#a-php-mongodb-query-builder-library)

Install via Packagist and Composer
----------------------------------

[](#install-via-packagist-and-composer)

Add the following into your composer.json file:

```
{
    "require": {
        "fahmiardi/mongoqb": "*"
    }
}
```

Then run

```
composer install
```

Install via Git
---------------

[](#install-via-git)

```
git clone git://git@github.com:alexbilbie/MongoQB
```

Download a zip/tarball
----------------------

[](#download-a-ziptarball)

Download the latest version:

- [zip](https://github.com/alexbilbie/MongoQB/archive/master.zip)
- [tar](https://github.com/alexbilbie/MongoQB/archive/master.tar.gz)

(Note the zip/tarball won't include any unit tests or composer files)

Unit tests
----------

[](#unit-tests)

Master branch [![Build Status](https://camo.githubusercontent.com/37369404d3e6b3b8f1982f7f25c532315c083e30b323e269c29e65e87a4703c5/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f616c657862696c6269652f4d6f6e676f51422e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/alexbilbie/MongoQB)

Develop branch [![Build Status](https://camo.githubusercontent.com/5a03f9b5ba13399865f0021cac72a7102b727fde33e2aaca5d95a7d6ad3a6ecc/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f616c657862696c6269652f4d6f6e676f51422e706e673f6272616e63683d646576656c6f70)](https://travis-ci.org/alexbilbie/MongoQB)

The library currently has 100% unit test coverage. To run the unit test suite make sure you have MongoDB installed locally and running with no authentication and on the default port - 27017.

Then run:

```
composer update --dev
cd vendor/alexbilbie/mongoqb
phpunit -c tests/phpunit.xml
```

Example usage
-------------

[](#example-usage)

### Connect to the database

[](#connect-to-the-database)

```
$qb = \MongoQB\Builder(array(
    'dsn'   =>  'mongodb://user:pass@localhost:27017/databaseName'
);
```

### Insert a document

[](#insert-a-document)

```
$qb->insert('collectionName', [
    'name'  =>  'Alex',
    'age'   =>  22,
    'likes' =>  ['whisky', 'gin']
]);
```

### Update a single document

[](#update-a-single-document)

```
$qb
    ->where(['name' => 'Alex'])
    ->set([
        'country' => 'UK',
        'job' => 'Developer'
    ])
    ->push('likes', ['PHP', 'coffee'])
    ->update('collectionName');
```

### Delete a single document

[](#delete-a-single-document)

```
$qb
    ->where(['name' => 'Alex'])
    ->delete('collectionName');
```

### Search for matching documents

[](#search-for-matching-documents)

```
$results = $qb
    ->whereGt('age', 21)
    ->whereIn('likes', ['whisky'])
    ->where('country', 'UK')
    ->get('collectionName');
```

If you find any bugs please file a report in the [Issue tracker](https://github.com/alexbilbie/MongoQB/Issues)

If you find this software useful please consider donating, thank you =\]

[![https://www.paypalobjects.com/en_US/GB/i/btn/btn_donateCC_LG.gif](https://camo.githubusercontent.com/0293c3ea1e6dbe13508306375f69c8d21d79fce0478eb6f60e84c512d7e5192c/68747470733a2f2f7777772e70617970616c6f626a656374732e636f6d2f656e5f55532f47422f692f62746e2f62746e5f646f6e61746543435f4c472e676966)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=MWFMPM8LDQ7GC)

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 92.6% 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 ~102 days

Recently: every ~200 days

Total

9

Last Release

4165d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3264535342f6dd2bacce6425cb96c32d6113e25e3adac91a11660be332e764eb?d=identicon)[fahmiardi](/maintainers/fahmiardi)

---

Top Contributors

[![alexbilbie](https://avatars.githubusercontent.com/u/77991?v=4)](https://github.com/alexbilbie "alexbilbie (87 commits)")[![fahmiardi](https://avatars.githubusercontent.com/u/1201482?v=4)](https://github.com/fahmiardi "fahmiardi (7 commits)")

---

Tags

databasedbmongodbmongo

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k8.0M90](/packages/mongodb-laravel-mongodb)[danielme85/laravel-log-to-db

Custom Laravel Log channel handler that can store log events to SQL or MongoDB databases. Uses Laravel native logging functionality.

134979.2k1](/packages/danielme85-laravel-log-to-db)[moloquent/moloquent

A MongoDB based Eloquent model and Query builder for Laravel (Moloquent)

120115.3k7](/packages/moloquent-moloquent)[moriony/silex-mongo-provider

Mongo service provider for the Silex framwork.

118.5k](/packages/moriony-silex-mongo-provider)

PHPackages © 2026

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