Check MongoDB php driver version Check MongoDB php driver version unix unix

Check MongoDB php driver version


Legacy PECL Extension

The easiest way on the command line is by invoking reflection info:

$ php --ri mongo | grep Version

will output for example:

Version => 1.4.4

This will run ReflectionExtension::info() on the mongo extension, and grep the Version column.

Couple of other alternatives would be to execute some code, and print out the version information.

The MongoClient class (and the Mongo class for old extensions) as a VERSION constant:

$ php -r 'echo MongoClient::VERSION, "\n";'

will output (for example):

1.4.4

Or you could use the phpversion function to retrieve the version number from the module initialization:

$ php -r 'echo phpversion("mongo"), "\n";'

will output (for example):

1.4.4

EDIT - New Extension:

The above refers to the now-old and legacy pecl/mongo extension.There is a new extension called pecl/mongodb.

Similar commands work for the new extension:

$ php --ri mongodb | grep versionmongodb version => 1.1.2libmongoc version => 1.3.1-devlibbson version => 1.3.0$ php -r 'echo MONGODB_VERSION, "\n";'1.2.2$ php -r 'echo phpversion("mongodb"), "\n";'1.2.2$ php -dmongodb.debug=stdout -r 'new MongoDB\Driver\Manager;' | grep Creating[2016-03-01T17:59:23+00:00]     PHONGO: DEBUG   > Creating Manager, phongo-1.1.2[stable] - mongoc-1.3.1-dev(bundled), libbson-1.3.0(bundled), php-5.6.16


Use pecl to check the current local version and the latest version available:

pecl search mongo

You should see this information:

Package Stable/(Latest) Localmongo   1.x.x (stable)  1.x.x MongoDB database driver


For recent versions, the command is php --ri mongodb.