检查 MongoDB php 驱动程序版本

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19034006/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 18:42:33  来源:igfitidea点击:

Check MongoDB php driver version

phpmongodbunix

提问by dykw

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?

几个月前,我在 Linux 机器上安装了 MongoDB PHP 驱动程序。现在,我想知道我安装了哪个版本的驱动程序。我怎样才能找到这些信息?

回答by bjori

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.

这将在 mongo 扩展上运行ReflectionExtension::info(),并 grep 版本列。

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

其他几种替代方法是执行一些代码,并打印出版本信息。

The MongoClientclass (and the Mongo class for old extensions) as a VERSIONconstant:

所述MongoClient类(以及旧的扩展蒙戈类)作为VERSION常数:

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

will output (for example):

将输出(例如):

1.4.4

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

或者您可以使用phpversion函数从模块初始化中检索版本号:

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

will output (for example):

将输出(例如):

1.4.4


EDIT:

编辑:

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

以上指的是现在旧的和遗留的pecl/mongo扩展。有一个名为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

回答by anhlc

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

使用 pecl 检查当前本地版本和可用的最新版本:

pecl search mongo

You should see this information:

您应该会看到以下信息:

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

回答by olvlvl

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

对于最新版本,命令是php --ri mongodb.

回答by Satish

Run PHP test and check MongoDBsection

运行 PHP 测试和检查MongoDB部分

<?php phpinfo(); ?>