PHPackages                             thomas-squall/php7-mongo-driver - 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. thomas-squall/php7-mongo-driver

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

thomas-squall/php7-mongo-driver
===============================

PHP7 Driver for MongoDb

0.7.4(7y ago)121572MITPHPPHP ^7.0

Since Jan 5Pushed 7y ago6 watchersCompare

[ Source](https://github.com/ThomasSquall/PHP7MongoDriver)[ Packagist](https://packagist.org/packages/thomas-squall/php7-mongo-driver)[ RSS](/packages/thomas-squall-php7-mongo-driver/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (5)Dependencies (2)Versions (11)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.

**!!! FOR DETAILED GUIDELINES CONSULT THE WIKI AT:**

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

[](#installation)

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

```
$ composer require thomas-squall/php7-mongo-driver
```

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 :)

Thomas

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity54

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

Recently: every ~27 days

Total

9

Last Release

2703d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7748020?v=4)[Thomas Cocchiara](/maintainers/ThomasSquall)[@ThomasSquall](https://github.com/ThomasSquall)

---

Top Contributors

[![ThomasSquall](https://avatars.githubusercontent.com/u/7748020?v=4)](https://github.com/ThomasSquall "ThomasSquall (81 commits)")

---

Tags

mongodbphp-libraryphp7

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/thomas-squall-php7-mongo-driver/health.svg)

```
[![Health](https://phpackages.com/badges/thomas-squall-php7-mongo-driver/health.svg)](https://phpackages.com/packages/thomas-squall-php7-mongo-driver)
```

###  Alternatives

[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k117.2M117](/packages/jdorn-sql-formatter)[propel/propel1

Propel is an open-source Object-Relational Mapping (ORM) for PHP5.

8351.6M87](/packages/propel-propel1)[jfelder/oracledb

Oracle DB driver for Laravel

11518.4k](/packages/jfelder-oracledb)

PHPackages © 2026

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