PHPackages                             district5/mondoc-builder - 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. district5/mondoc-builder

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

district5/mondoc-builder
========================

A simple to use object orientated library to generate queries to use in MongoDB

2.3.1(12mo ago)0610—1.6%1mitPHPPHP &gt;=8.4CI passing

Since Apr 3Pushed 12mo agoCompare

[ Source](https://github.com/district-5/php-mondoc-builder)[ Packagist](https://packagist.org/packages/district5/mondoc-builder)[ Docs](https://github.com/district-5/php-mondoc-builder)[ RSS](/packages/district5-mondoc-builder/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (3)Versions (12)Used By (1)

Mondoc Builder, by District5
============================

[](#mondoc-builder-by-district5)

[![CI](https://github.com/district-5/php-mondoc-builder/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/district-5/php-mondoc-builder/actions)[![Latest Stable Version](https://camo.githubusercontent.com/2f81812b7ef6ade98f43c3d3d72e988e987bf2ed3bbf1b35d396778a930b2e48/687474703a2f2f706f7365722e707567782e6f72672f6469737472696374352f6d6f6e646f632d6275696c6465722f76)](https://packagist.org/packages/district5/mondoc-builder)[![PHP Version Require](https://camo.githubusercontent.com/b03c02512d5bfb4513d0bc7b861c769e6a57585a880c883b0bc19765cc2e0089/687474703a2f2f706f7365722e707567782e6f72672f6469737472696374352f6d6f6e646f632d6275696c6465722f726571756972652f706870)](https://packagist.org/packages/district5/mondoc-builder)[![Codecov](https://camo.githubusercontent.com/cff6f21d295d72cf37723c361d6d1aff096378494f1046f5631d1dcf9a1570e8/68747470733a2f2f636f6465636f762e696f2f67682f64697374726963742d352f7068702d6d6f6e646f632d6275696c6465722f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/district-5/php-mondoc-builder)

[![FOSSA Status](https://camo.githubusercontent.com/e4cfbe57d651833e62e77f8568aca24b0d2c07c4647c465c42af4d23e6651b45/68747470733a2f2f6170702e666f7373612e636f6d2f6170692f70726f6a656374732f6769742532426769746875622e636f6d25324664697374726963742d352532467068702d6d6f6e646f632d6275696c6465722e7376673f747970653d736d616c6c)](https://app.fossa.com/projects/git%2Bgithub.com%2Fdistrict-5%2Fphp-mondoc-builder?ref=badge_small)

#### A MongoDB query building library.

[](#a-mongodb-query-building-library)

### Installation...

[](#installation)

```
composer require district5/mondoc-builder
```

### Testing and fixing...

[](#testing-and-fixing)

- Install dependencies: ```
    $ composer install

    ```
- Run PHPUnit ```
    $ ./vendor/bin/phpunit

    ```

### Building a query...

[](#building-a-query)

The core function of this library is to build queries that can be used in Mongo.

Getting an instance of QueryBuilder

```
use District5\MondocBuilder\QueryBuilder;

$builder = QueryBuilder::get(); // or $builder = new \District5\MondocBuilder\QueryBuilder();
```

Assigning options to the QueryBuilder (skip / limit / sort and custom options)

```
