PHPackages                             eman-development-design/mongodb-helpers - 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. eman-development-design/mongodb-helpers

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

eman-development-design/mongodb-helpers
=======================================

Helper Objects to make writing MongoDB apps easier.

1.0.5(5y ago)113[1 issues](https://github.com/eman-development-design/mongodb-helpers/issues)MITPHPPHP &gt;=7.2.0

Since Jun 3Pushed 1y agoCompare

[ Source](https://github.com/eman-development-design/mongodb-helpers)[ Packagist](https://packagist.org/packages/eman-development-design/mongodb-helpers)[ Docs](http://emandevelopmentdesign.com)[ RSS](/packages/eman-development-design-mongodb-helpers/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (6)Dependencies (1)Versions (9)Used By (0)

mongodb-helpers
===============

[](#mongodb-helpers)

Helper Objects to make writing MongoDB apps easier.

Helpers
-------

[](#helpers)

### Sorting Helper

[](#sorting-helper)

You can easily add sorting by extending `DataSorting`

```
class UserSorting extends DataSorting
{
    public const Email = 'Email';

    public const FirstName = 'FirstName';

    public const LastName = 'LastName';
}
```

you can then use it like so:

```
UserSorting::AddToSortList(UserSorting::FirstName, UserSorting::ASC);
```

you then compile the sort list by doing this:

```
$sort = UserSorting::GetSortList();
```

this wil allow you you add as many sorting rules as you want to a query.

### Model Helper

[](#model-helper)

`MongoModelInterface` is an interface helper that'll provide some helper methods for handling model data.

```
use MongoDB\BSON\Serializable;
use MongoDB\Model\BSONDocument;
use Edd\MongoDbHelpers\MongoModelInterface

class User implements Serializable, MongoModelInterface
{
    public $userGuid;
    public $email;
    public $firstName;
    public $lastName;

    public function bsonSerialize() : array
    {
        return [
            'UserUuid' => $this->userUuid,
            'Email' => $this->email,
            'FirstName' => $this->firstName,
            'LastName' => $this->lastName
        ];
    }

    public function map(BSONDocument $document)
    {
        $this->userUuid = $document['UserUuid'];
        $this->email = $document['Email'];
        $this->firstName = $document['FirstName'];
        $this->lastName = $document['LastName'];
    }

    public function toArray() : array
    {
        return get_object_vars($this);
    }
}
```

`map` helps you map a BSON Document result to your model properties.

`toArray` is for presenting the data as an array.

### Repository Helper

[](#repository-helper)

`MongoRepository` makes it easy to setup a basic repository style architecture, the constructor will create an instance of `MongoDB\Client` .

`SetCollection` &amp; `GetCollection` setup and provide an instance of `MongoDB\Collection`.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance16

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity59

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 ~361 days

Recently: every ~539 days

Total

7

Last Release

371d ago

Major Versions

1.0.5 → 2.0.x-dev2024-11-29

PHP version history (3 changes)1.0.0PHP ^7.2.0

1.0.5PHP &gt;=7.2.0

2.0.x-devPHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/96b5243c34bdd31f20345e5963f22d733c0b985b6b24a193eebcaeed968d7611?d=identicon)[eman-development-design](/maintainers/eman-development-design)

---

Top Contributors

[![eman1986](https://avatars.githubusercontent.com/u/2343334?v=4)](https://github.com/eman1986 "eman1986 (25 commits)")

---

Tags

composer-packagehelperslibrarymongodbphphelpermodelmongodbrepositorymongosorting

### Embed Badge

![Health badge](/badges/eman-development-design-mongodb-helpers/health.svg)

```
[![Health](https://phpackages.com/badges/eman-development-design-mongodb-helpers/health.svg)](https://phpackages.com/packages/eman-development-design-mongodb-helpers)
```

###  Alternatives

[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

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

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

120114.6k7](/packages/moloquent-moloquent)

PHPackages © 2026

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