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.