PHPackages                             alex-qiu/php7-mongo-adapter - 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. alex-qiu/php7-mongo-adapter

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

alex-qiu/php7-mongo-adapter
===========================

php7 mongodb adapter

v0.0.1(7y ago)022MITPHPPHP ^7.0

Since Nov 7Pushed 7y ago1 watchersCompare

[ Source](https://github.com/alexQi/php7-mongo-adapter)[ Packagist](https://packagist.org/packages/alex-qiu/php7-mongo-adapter)[ RSS](/packages/alex-qiu-php7-mongo-adapter/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

MongoDriver for PHP7
====================

[](#mongodriver-for-php7)

[![Latest Stable Version](https://camo.githubusercontent.com/f46edbe5336af239c5d32b6cc9bc553d608d5ad138bcf4221d2e1ab8a0d583b1/68747470733a2f2f706f7365722e707567782e6f72672f74686f6d61732d737175616c6c2f706870372d6d6f6e676f2d6472697665722f762f737461626c652e737667)](https://packagist.org/packages/thomas-squall/php7-mongo-driver)[![Build Status](https://camo.githubusercontent.com/7cb4bbcf75cfc44d8b60659bac124a5b5a912f6a6e322151f3450233b12356d5/68747470733a2f2f7472617669732d63692e6f72672f54686f6d6173537175616c6c2f504850374d6f6e676f4472697665722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/ThomasSquall/PHP7MongoDriver)[![Coverage Status](https://camo.githubusercontent.com/212b203e9232f64172e2fbe18d1864435089d740ff265636a66e63f403088664/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f54686f6d6173537175616c6c2f504850374d6f6e676f4472697665722f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/ThomasSquall/PHP7MongoDriver?branch=master)[![codecov](https://camo.githubusercontent.com/ffc150bdecbc65f3aa0ec1887b5fd5b48c8da8def9eb29a07af743f819349649/68747470733a2f2f636f6465636f762e696f2f67682f54686f6d6173537175616c6c2f504850374d6f6e676f4472697665722f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/ThomasSquall/PHP7MongoDriver)[![Total Downloads](https://camo.githubusercontent.com/6de28f07aa53e5dfe269d1ba58cc9e0c658c0b27ab73853c17685474b24fcbe5/68747470733a2f2f706f7365722e707567782e6f72672f74686f6d61732d737175616c6c2f706870372d6d6f6e676f2d6472697665722f646f776e6c6f6164732e737667)](https://packagist.org/thomas-squall/php7-mongo-driver)[![License](https://camo.githubusercontent.com/46c08451f51d9cf99fb9237578dcb18cdbbc15d5913f5a494a5f276d8bd92d80/68747470733a2f2f706f7365722e707567782e6f72672f74686f6d61732d737175616c6c2f706870372d6d6f6e676f2d6472697665722f6c6963656e73652e737667)](https://packagist.org/packages/thomas-squall/php7-mongo-driver)

With the advent of PHP7 the old mongodb driver is no more supported.

The new driver available is a little bit low-level compared to the previous one so it can be a bit complicated to work with.

This is what this library was conceived for.

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

[](#installation)

Using composer is quite simple, just run the following command:

```
$ composer require alex-qiu/php7-mongo-adapter
```

Prerequisites
-------------

[](#prerequisites)

Before using this library you should make sure to have installed PHP7.0 or major and MongoDb driver from pecl.

For those using a Linux distribution (make sure to have pecl installed) just run:

```
$ sudo pecl install mongodb
```

After that you should put the following string

```
extension=mongodb.so
```

Inside your php.ini

Usage
-----

[](#usage)

At first you need to define a connection string.

The format for connection strings is:

```
mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]]

```

For more information see the link:

Once defined you need to instantiate a new Adapter:

```
use MongoDriver\Adapter;

// Enstablish a connection.
$adapter = new Adapter();
$adapter->connect(CONNECTION_STRING);
```

At this point you want to select a Database where do your query:

```
$adapter->selectDB('myDatabase');
```

NOTE: you could select a database directly on the constructor passing the database name as the 2nd parameter.

### Find

[](#find)

Once selected the database we can simply query for the collection we want:

```
$items = $adapter->find('myCollection');
```

You can also filter your query:

```
use MongDriver\Filter;

$filters =
[
    new Filter('myField1', 'myValue1', Filter::IS_EQUALS),
    new Filter('myField2', ['myValue2', 'myValue3'], Filters::IS_IN_ARRAY)
];

$items = $adapter->find('myCollection', $filters);
```

### Insert

[](#insert)

If you want to insert an item you have simply to pass an array or an object to the insert function specifying the collection:

```
$item = new Person();
$item->name = 'Thomas';
$item->surname = 'Cocchiara');

// or: $item = ['name' => 'Thomas', 'surname' => 'Cocchiara'];

$adapter->insert('people', $item);
```

Hope you guys find this library useful.

Please share it and give me a feedback :)

Alex

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity46

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

Unknown

Total

1

Last Release

2744d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8038522516d023f702b6adf8ea01b5420e346bfa8bfc5f4dd2b8b892ece8b42e?d=identicon)[alexQi](/maintainers/alexQi)

---

Top Contributors

[![alexQi](https://avatars.githubusercontent.com/u/15188545?v=4)](https://github.com/alexQi "alexQi (3 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/alex-qiu-php7-mongo-adapter/health.svg)

```
[![Health](https://phpackages.com/badges/alex-qiu-php7-mongo-adapter/health.svg)](https://phpackages.com/packages/alex-qiu-php7-mongo-adapter)
```

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[mongodb/mongodb

MongoDB driver library

1.6k64.0M546](/packages/mongodb-mongodb)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90340.3M211](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)

PHPackages © 2026

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