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
bjori
source share