4

I'm a beginner in MongoDB handling with php.

I'm using Windows 8 (64bit), PHP 5.4.3, PHP Extension Build API20100525,TS,VC9 and mongodb-win32-x86_64-2.2.2.

I tried to install the mongodb driver from https://github.com/mongodb/mongo-php-driver/downloads

Downloaded the first package and there were 10 driver files inside the package. I tried with each of those last four drivers which capable of php 5.4 Then found the php.ini file and included the given corresponding line with the driver name. (ex: extension=php_mongo-1.3.2RC1-5.4-vc9-x86_64.dll)

But none of them responded me. I tried the following sample code to evaluate them.

<?php

// connect
$m = new MongoClient();

// select a database
$db = $m->test;

// select a collection (analogous to a relational database's table)
$collection = $db->shafny;

// add a record
$document = array( "name" => "Anderson", "age" => 22 );
$collection->insert($document);


// find everything in the collection
$cursor = $collection->find();

// iterate through the results
foreach ($cursor as $document) {
echo $document["name"] . "\n";
}

?>

The I got an error message,

Fatal error: Class 'MongoClient' not found in C:\Wamp\www\Mongo\test.php on line 5

I hope this unknown class error is raising due to the lack of proper installation of driver. So please anyone guide me to over come this issue.

1 Answer 1

2

If you are using WAMP, you should edit the PHP.ini file in C:\wamp\bin\apache's bin folder or where ever your WAMP Apache PHP.ini file is. Or if you use the Apache installed separately edit its PHP.ini. I think you have edited the PHP.ini in the PHP folder.

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.