Php over MongoDB

I am starting to work with MongoDB using php.

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

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

We downloaded the first package and it had 10 driver files. I tried with each of these last four drivers capable of php 5.4. Then I found the php.ini file and included this corresponding line with the name of the driver. (for example: extension = php_mongo-1.3.2RC1-5.4-vc9-x86_64.dll)

But none of them answered me. I tried the following code example to evaluate them.

<?php // connect $m = new MongoClient(); // select a database $db = $m->test; // select a collection (analogous to a relational database 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"; } ?> 

I got an error message,

Fatal error: class "MongoClient" was not found in C: \ Wamp \ www \ Mongo \ test.php on line 5

I hope this unknown class error is raised due to the lack of a proper driver installation. So please, let me lead me to this problem.

+4
source share
1 answer

If you use WAMP, you must edit the PHP.ini file in the C: \ wamp \ bin \ apache bin folder or your WAMP Apache PHP.ini file somewhere. Or if you are using Apache installed separately, edit it with PHP.ini. I think you edited PHP.ini in the PHP folder.

+2
source

All Articles