Check MongoDB php driver version

I installed the PHP MongoDB driver on my Linux computer a few months ago. Now I want to find out which version of the driver I installed. How can I find this information?

+8
unix php mongodb
source share
4 answers

The easiest way on the command line is to call up reflection information:

$ php --ri mongo | grep Version 

will be displayed, for example:

 Version => 1.4.4 

This will result in ReflectionExtension :: info () in the mongo and grep extension in the Version column.

A couple of other alternatives would be to execute some code and print version information.

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

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

will be output (for example):

 1.4.4 

Or you can use the phpversion function to extract the version number from the module initialization:

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

will be output (for example):

 1.4.4 

EDIT:

The above refers to the current and obsolete pecl / mongo extension . There is a new extension called pecl / mongodb .

Similar commands work for the new extension:

 $ php --ri mongodb | grep version mongodb version => 1.1.2 libmongoc version => 1.3.1-dev libbson 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 
+33
source share

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

 pecl search mongo 

You should see this information:

 Package Stable/(Latest) Local mongo 1.xx (stable) 1.xx MongoDB database driver 
+5
source share

Run the PHP test and check the MongoDB section

 <?php phpinfo(); ?> 
+2
source share

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

0
source share

All Articles