I installed the MongoDB PHP driver on my Linux machine a few months ago. Now, I want to know which version of the driver I installed. How can I find this information?
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
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 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
Use pecl to check the current local version and the latest version available:
pecl search mongo
You should see this information:
Package Stable/(Latest) Local
mongo 1.x.x (stable) 1.x.x MongoDB database driver
For recent versions, the command is php --ri mongodb
.
Run PHP test and check MongoDB
section
<?php phpinfo(); ?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With