0

I am using XAMPP, PHP Version 5.3.5.

I installed mongodb.

I tried to connect mongo db from my php code, it gives me error

$connection = new MongoClient("mongodb://localhost");
$db = $connection->dbname;

echo $db;

Fatal error: Class 'MongoClient' not found in C:\xampp\htdocs\test\test.php on line 9

I guess it is because, I installed a old version of php-mongo driver.

What is the proper version of php-mongo driver for PHP Version 5.3.5 ?

1 Answer 1

1

The current version of the MongoDB driver for PHP is 1.3.4.

The class Mongo was deprecated with version 1.3 and replaced with MongoClient. Apparently you are using an older version than 1.3 in your install.

http://pecl.php.net/package/mongo

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

2 Comments

Apparently the latest stable version for Windows versions is still 1.3.1, which you can download here They don't seem to be that keen on being up-to-date. It does contain MongoClient already though, since I'm still using that version
Thank you , let me go through it :)

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.