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 PHP7.
This library aims to provide a compatibility layer for applications that rely on on libraries using ext-mongo (e.g. Doctrine 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.
This library is still in development and not stable enough to be used in production. In addition to the known issues outlined below, other issues or fatal errors may occur. Please use at your own risk.
This library requires you to have the mongodb extension installed and conflicts with the legacy mongo extension.
The preferred method of installing this library is with Composer by running the following from your project root:
$ composer require "alcaeus/mongo-php-adapter=dev-master"
If your project includes a library that requires ext-mongo
you need to also
specify a provide
option in your composer.json:
"provide": {
"ext-mongo": "1.6.12"
}
Due to a limitation in composer you need to specify this in the root package.
- 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.
- The MongoLog class does not log anything because the underlying driver does not offer a method to retrieve this data.
- The connect and close methods are not implemented because the underlying driver connects lazily and does not offer methods for connecting disconnecting.
- The getConnections method is not implemented because the underlying driver does not offer a method to retrieve this data.
- The killCursor method is not yet implemented.
- The authenticate method is not supported. To connect to a database with authentication, please supply the credentials using the connection string.
- The
includeSystemCollections
parameter used in the getCollectionInfo, getCollectionNames, and listCollections methods is ignored. These methods do not return information about system collections. - The repair method is not yet implemented.
- The createIndex method does not yet return the same result as the original method. Instead, it always returns the name of the index created.
- The insert, batchInsert, and save 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 method is not yet implemented.
- The explain method is not yet implemented.
- The hasNext method is not yet implemented.
- The setFlag method is not yet implemented.
- The createFromDocument method is not yet implemented.
- Return values containing objects of the MongoDB\BSON\Javascript class cannot be converted to full MongoCode objects because there are no accessors for the code and scope properties.