Fix This Page
Navigation

PHP MongoDB Driver

For the official MongoDB PHP Driver reference, see:

Drivers

The currently maintained driver is the mongodb extension available from PECL. This driver can be used stand-alone, although it is very bare-bones. You should consider using the driver with the complimentary PHP library, which implements a more full-featured API on top of the bare-bones driver. Further information on this architecture may be found in the PHP.net documentation.

The mongo extension available from PECL is an older, legacy driver for PHP 5.x. The mongo extension is no longer maintained and new projects are advised to use the mongodb extension and PHP library. A community-developed Mongo PHP Adapter project implements the legacy mongo extension’s API using the new mongodb extension and PHP library, which may be useful for those wishing to migrate existing applications.

Compatibility

MongoDB Compatibility

The following compatibility table specifies the recommended version(s) of the MongoDB PHP driver for use with a specific version of MongoDB.

The first column lists the driver version(s).

In the table below, mongodb and mongo refer to the new and legacy MongoDB PHP driver, respectively. PHPLIB refers to the userland library.

PHP Driver MongoDB 2.4 MongoDB 2.6 MongoDB 3.0 MongoDB 3.2 MongoDB 3.4
PHPLIB 1.1 + mongodb-1.2
PHPLIB 1.0 + mongodb-1.1  
mongodb-1.1  
mongodb-1.0    
mongo-1.6    
mongo-1.5      

For additional driver versions, see PHP Driver MongoDB Compatibility Reference.

The driver does not support older versions of MongoDB.

Language Compatibility

The following compatibility table specifies the recommended version(s) of the MongoDB PHP driver for use with a specific version of PHP.

The first column lists the driver version(s).

In the table below, mongodb and mongo refer to the new and legacy MongoDB PHP driver, respectively.

PHP Driver PHP 5.3 PHP 5.4 PHP 5.5 PHP 5.6 PHP 7.0 PHP 7.1 HHVM 3.12 HHVM 3.15
mongodb-1.2  
mongodb-1.1    
mongodb-1.0        
mongo-1.6        
mongo-1.5        

For additional driver versions, see PHP Driver Language Compatibility Reference.