Paul
Paul

Reputation: 367

MongoDB not working with PHP on WAMP

I have been having trouble with getting MongoDB and php working together:

( ! ) Fatal error: Class 'Mongo' not found in C:\wamp\www\mongoDBTest\index.php on line 6

Here are my details:

MongoDB works fine on it's own and I have created the data/db folder.

I have tried adding php_mongo.dll to my php ext folder using the file "php_mongo-1.3.1-5.4-vc9-x86_64.dll" and then renaming it and adding the relevent extension in the php.ini file.

I also know about this site and not found anything useful http://www.php.net/manual/en/mongo.installation.php#mongo.installation.windows

Upvotes: 2

Views: 5566

Answers (2)

RiggsFolly
RiggsFolly

Reputation: 94642

Thats becasue the mongoDB extension does nto come with WAMP by default.

You have to install it yourself,

here is a starter for 10

Second try:

When you run the wamp home page and then phpinfo(), does mongoDB show up in the installed list?

Secondly can you run a command window and cd into \wamp\bin\php\php5.4.x And run

php.exe -i

Then check

Compiler => ??????????
Architecture => ???

Of course it might be worth checking that you are trying to instantiate the correct object. According to the manual this is the way its should be done.

$connection = new MongoClient(); // connects to localhost:27017
$connection = new MongoClient( "mongodb://example.com" ); // connect to a remote host (default port: 27017)
$connection = new MongoClient( "mongodb://example.com:65432" ); // connect to a remote host at a given port

Upvotes: 0

Ivo Pereira
Ivo Pereira

Reputation: 3500

I am supposing you have restarted WAMP after changing the php.ini extensions. At first, try to add the MongoDB in your ENVIRONMENT PATH and restart computer (you would be surprised by the amount of problems the restart does solve).

When changing the php.ini try either to do not change the DLL name, and add it the way you downloaded it.

You can check some of this tips in detail clicking here.

Upvotes: 1

Related Questions