2

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:

  • system: Windows NT LAPBTN1894 6.1 build 7600 (Windows 7 Enterprise Edition) AMD64
  • Architecture: x64
  • Apache/PHP: Apache/2.4.4 (Win64) PHP/5.4.12 thread safe
  • Compiler: MSVC9 (Visual C++ 2008)
  • MongoDB: 2.4.5

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

Paul
  • 367
  • 3
  • 18

2 Answers2

1

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.

Ivo Pereira
  • 3,410
  • 1
  • 19
  • 24
  • 1
    That was perfect, exactly what I needed. I uninstalled WAMP and MongoDB and re-installed using that guide and it works great now. Thank you very much :) – Paul Aug 19 '13 at 16:35
  • Watch this link http://stackoverflow.com/questions/27894906/mongodb-php-driver-installation-issue-on-wamp – Mad Angle Jul 27 '16 at 13:39
0

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
RiggsFolly
  • 93,638
  • 21
  • 103
  • 149