PHPackages                             pvodicka/mongo-php-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. pvodicka/mongo-php-adapter

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

pvodicka/mongo-php-adapter
==========================

Adapter to provide ext-mongo interface on top of mongo-php-library. Modified to use my mongo-php-library fork.

1.1.6(8y ago)01.4kMITPHPPHP ^5.6 || ^7.0

Since Feb 6Pushed 8y ago1 watchersCompare

[ Source](https://github.com/pvodicka/mongo-php-adapter)[ Packagist](https://packagist.org/packages/pvodicka/mongo-php-adapter)[ RSS](/packages/pvodicka-mongo-php-adapter/feed)WikiDiscussions master Synced today

READMEChangelog (3)Dependencies (2)Versions (23)Used By (0)

Modified to use my mongo-php-library instead of mongodb original. Not recomended for production enviroment!

Mongo PHP Adapter
=================

[](#mongo-php-adapter)

[![Build Status](https://camo.githubusercontent.com/842933f8c27753cf27ec80bdf78a0c7baf2195ebf3706d03dc6f47ccde0da095/68747470733a2f2f7472617669732d63692e6f72672f616c63616575732f6d6f6e676f2d7068702d616461707465722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/alcaeus/mongo-php-adapter)[![Code Coverage](https://camo.githubusercontent.com/f33278cf036a6205535bdde02a16ffe6546175069f35cf743fe2fafb4bb3b3d5/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f616c63616575732f6d6f6e676f2d7068702d616461707465722f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/alcaeus/mongo-php-adapter/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/77ff4deafa03a32cc7dd7262b98bc8a9f92b737cf186ee238ac27813f9ce8ea4/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f616c63616575732f6d6f6e676f2d7068702d616461707465722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/alcaeus/mongo-php-adapter/?branch=master)

The Mongo PHP Adapter is a userland library designed to act as an adapter between applications relying on ext-mongo and the new driver (`ext-mongodb`).

It provides the API of ext-mongo built on top of mongo-php-library, thus being compatible with PHP 7.

Goal
====

[](#goal)

This library aims to provide a compatibility layer for applications that rely on libraries using ext-mongo, e.g. [Doctrine MongoDB ODM](https://github.com/doctrine/mongodb-odm), but want to migrate to PHP 7 or HHVM on which `ext-mongo` will not run.

You should not be using this library if you do not rely on a library using `ext-mongo`. If you are starting a new project, please check out [mongodb/mongodb](https://github.com/mongodb/mongo-php-library).

Installation
============

[](#installation)

This library requires you to have the `mongodb` extension installed, and it conflicts with the legacy `mongo` extension.

The preferred method of installing this library is with [Composer](https://getcomposer.org/) by running the following from your project root:

```
$ composer config "platform.ext-mongo" "1.6.16" && composer require alcaeus/mongo-php-adapter

```

The above command first marks the `mongo` extension as installed, then requires this adapter. This is to work around a bug in composer, see [composer/composer#5030](https://github.com/composer/composer/issues/5030).

Known issues
============

[](#known-issues)

Return values and exceptions
----------------------------

[](#return-values-and-exceptions)

Some methods may not throw exceptions with the same exception messages as their counterparts in `ext-mongo`. Do not rely on exception messages being the same.

Methods that return a result array containing a `connectionId` field will always return `0` as connection ID.

Errors
------

[](#errors)

All errors and warnings triggered by `ext-mongo` are triggered as `E_USER_WARNING`and `E_USER_ERROR` because `trigger_error` doesn't accept the `E_WARNING` and `E_USER` codes. If you rely on these error codes in your error handling routines, please update your code accordingly.

Serialization of objects
------------------------

[](#serialization-of-objects)

Serialization of any Mongo\* objects (e.g. MongoGridFSFile, MongoCursor, etc.) will not work properly. The objects can be serialized but are not usable after unserializing them.

Mongo
-----

[](#mongo)

- The Mongo class is deprecated and was not implemented in this library. If you are still using it please update your code to use the new classes.

MongoLog
--------

[](#mongolog)

- The [MongoLog](http://php.net/manual/en/class.mongolog.php) class does not log anything because the underlying driver does not offer a method to retrieve this data.

MongoClient
-----------

[](#mongoclient)

- The [connect](https://php.net/manual/en/mongoclient.connect.php) and [close](https://secure.php.net/manual/en/mongoclient.close.php) methods are not implemented because the underlying driver connects lazily and does not offer methods for connecting disconnecting.
- The [getConnections](https://secure.php.net/manual/en/mongoclient.getconnections.php)method is not implemented because the underlying driver does not offer a method to retrieve this data.
- The [killCursor](https://php.net/manual/en/mongoclient.killcursor.php) method is not yet implemented.

MongoDB
-------

[](#mongodb)

- The [authenticate](https://secure.php.net/manual/en/mongodb.authenticate.php)method is not supported. To connect to a database with authentication, please supply the credentials using the connection string.
- The `$cmd` collection cannot be used due to an issue in the underlying driver. To run commands, use the [command](https://secure.php.net/manual/en/mongodb.command.php)method instead of querying the virtual `$cmd` collection.

MongoCollection
---------------

[](#mongocollection)

- The [insert](https://php.net/manual/en/mongocollection.insert.php), [batchInsert](https://php.net/manual/en/mongocollection.batchinsert.php), and [save](https://php.net/manual/en/mongocollection.save.php)methods take the first argument by reference. While the original API does not explicitely specify by-reference arguments it does add an ID field to the objects and documents given.
- The [parallelCollectionScan](https://php.net/manual/en/mongocollection.parallelcollectionscan.php)method is not yet implemented.

MongoCursor
-----------

[](#mongocursor)

- The [info](https://php.net/manual/en/mongocursor.info.php) method does not reliably fill all fields in the cursor information. This includes the `numReturned`and `server` keys once the cursor has started iterating. The `numReturned` field will always show the same value as the `at` field. The `server` field is lacking authentication information.
- The [setFlag](https://php.net/manual/en/mongocursor.setflag.php)method is not yet implemented.
- The [timeout](https://php.net/manual/en/mongocursor.timeout.php) method will not change any query options. Client-side timeouts are no longer supported by the new driver. Use the maxTimeMS setting as a replacement.

MongoCommandCursor
------------------

[](#mongocommandcursor)

- The [createFromDocument](https://php.net/manual/en/mongocommandcursor.createfromdocument.php)method is not yet implemented.
- The [info](https://php.net/manual/en/mongocommandcursor.info.php) method does not reliably fill all fields in the cursor information. This includes the `at`, `numReturned`, `firstBatchAt` and `firstBatchNumReturned` fields. The `at` and `numReturned`fields always return 0 for compatibility to MongoCursor. The `firstBatchAt` and `firstBatchNumReturned` fields will contain the same value, which is the internal position of the iterator.

Development
===========

[](#development)

If you are working on patches to this driver, you can run the unit tests by following these steps from the root of the repo directory:

```
$ composer install
$ vendor/phpunit/phpunit/phpunit --verbose

```

It assumes that the the `localhost` is running a mongod server. Here is a sample command to start mongod for these tests:

```
$ mongod --smallfiles --fork --logpath /var/log/mongod.log --setParameter enableTestCommands=1

```

The tests also assume PHP 5.6+ and the `ext-mongodb` extension being available.

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 95% 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 ~32 days

Total

22

Last Release

3063d ago

Major Versions

0.1.0 → 1.0.0-BETA12016-02-17

PHP version history (2 changes)0.1.0PHP ^5.5 || ^7.0

1.1.0PHP ^5.6 || ^7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/56094a80325a6b76cf5a1fdbb511233ca5e0c5602301ff24fe53ce1b2cc260aa?d=identicon)[pvodicka](/maintainers/pvodicka)

---

Top Contributors

[![alcaeus](https://avatars.githubusercontent.com/u/383198?v=4)](https://github.com/alcaeus "alcaeus (362 commits)")[![pvodicka](https://avatars.githubusercontent.com/u/4243219?v=4)](https://github.com/pvodicka "pvodicka (5 commits)")[![dzuelke](https://avatars.githubusercontent.com/u/27900?v=4)](https://github.com/dzuelke "dzuelke (2 commits)")[![damienalexandre](https://avatars.githubusercontent.com/u/225704?v=4)](https://github.com/damienalexandre "damienalexandre (2 commits)")[![idr0id](https://avatars.githubusercontent.com/u/524901?v=4)](https://github.com/idr0id "idr0id (1 commits)")[![jmikola](https://avatars.githubusercontent.com/u/244663?v=4)](https://github.com/jmikola "jmikola (1 commits)")[![martinatsli](https://avatars.githubusercontent.com/u/46876124?v=4)](https://github.com/martinatsli "martinatsli (1 commits)")[![peterrehm](https://avatars.githubusercontent.com/u/2010989?v=4)](https://github.com/peterrehm "peterrehm (1 commits)")[![vntw](https://avatars.githubusercontent.com/u/502368?v=4)](https://github.com/vntw "vntw (1 commits)")[![webmozart](https://avatars.githubusercontent.com/u/176399?v=4)](https://github.com/webmozart "webmozart (1 commits)")[![yurok1505](https://avatars.githubusercontent.com/u/2948566?v=4)](https://github.com/yurok1505 "yurok1505 (1 commits)")[![carusogabriel](https://avatars.githubusercontent.com/u/16328050?v=4)](https://github.com/carusogabriel "carusogabriel (1 commits)")[![DerManoMann](https://avatars.githubusercontent.com/u/47783?v=4)](https://github.com/DerManoMann "DerManoMann (1 commits)")[![emirb](https://avatars.githubusercontent.com/u/3412241?v=4)](https://github.com/emirb "emirb (1 commits)")

---

Tags

databasemongodb

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/pvodicka-mongo-php-adapter/health.svg)

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

###  Alternatives

[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

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

MongoDB driver library

1.6k64.0M545](/packages/mongodb-mongodb)[alcaeus/mongo-php-adapter

Adapter to provide ext-mongo interface on top of mongo-php-library

46412.3M73](/packages/alcaeus-mongo-php-adapter)[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.

135934.5k1](/packages/danielme85-laravel-log-to-db)[mongodb/mongodb-extension

MongoDB driver extension

91919.8k](/packages/mongodb-mongodb-extension)[dg/adminer-custom

Customization for Adminer, the best database management tool written in PHP.

134765.7k16](/packages/dg-adminer-custom)

PHPackages © 2026

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