1

In PHP how to check if the CORRECT mongodb PHP driver is installed for the corresponding mongodb.

The link below tells how to check if mongodb PHP driver is installed, but does not tell if that driver is correct/compatible for the corresponding mongodb.

http://stackoverflow.com/questions/11134959/check-if-mongodb-php-driver-is-installed

For example, if I have PHP version 5.3.10 and have mongodb 2.2.2, the command

echo extension_loaded("mongo") ? "loaded\n" : "not loaded\n";

will say loaded, however, mongodb is not going to work properly because for mongodb 2.2.2, you need the latest PHP not 5.3.10

7
  • I do not think such a check existed since drivers are designed to be backwards compatible when communicating to MongoDB as such theoretically all drivers should work for all versions. However I think it is common sense to know that if you got the latest MongoDB then the latest PHP driver is a good bet. Though driver 1.3 might have some breaking changes for older MongoDBs, not sure... Commented Nov 28, 2012 at 18:38
  • I do think there is a check on the pecl channel for PHP version so if that says nothing you should be fine, though the driver, again, is backward compatible for PHP versions as well. Commented Nov 28, 2012 at 18:44
  • Sammaye, thanks for your response. I know for a fact, mongodb 2.2.2 does not work with PHP 5.3.1 it works only with the latest PHP. We give our software that has PHP and mongodb to external companies. Most of these companies have PHP already installed so they just add the latest mongodb which does not work properly with old PHP. So we want to have a system in place to check this automatically when they start using our software. Commented Nov 28, 2012 at 18:57
  • I use php 5.3.0 with driver 1.2 and MongoDB 2.2...are you sure, absolutely sure compatibility is not maintained (haven't tried with the latest 1.3 release yet)? Commented Nov 28, 2012 at 19:10
  • Sammaye, some mongodb calls/syntax work and some don't work. We were able to reproduce this consistently. However, once we upgraded to PHP to latest everything worked fine. Commented Nov 28, 2012 at 19:23

1 Answer 1

1

I think, you're talking about driver, not PHP itself. PHP has no built-in support to access \Mongo* classes until you compile and load special extension.

Since you're talking about the latest version of MongoDB, I think you couldn't use some parts of its functionality because you had some old driver (say, 1.2.12). When you upgraded PHP, you, probably, updated the driver to the latest (1.3.0) stable version as well. That version of driver was submitted a couple of days ago, and it supports all the latest features MongoDB provides.

Anyway, if you'd like to check which version of driver you have, you can call phpinfo(8) from your PHP and look though the output for the mongo section, where the version of driver is displayed.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.