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

5
  • 1
    When you run phpinfo(), do you see any entries dealing with the mongo extension? Commented Aug 19, 2013 at 15:08
  • nope, it's like it knows nothing about it Commented Aug 19, 2013 at 15:21
  • Looks like you’ll have to teach PHP about Mongo then. Commented Aug 19, 2013 at 15:25
  • Can you link the pertinent areas of index.php? It can't find a php class. Did you add the class to index.php? Commented Aug 19, 2013 at 15:37
  • @Paul As far as I know there is no Mongo class, but there is a MongoClient class. Commented Aug 19, 2013 at 15:39

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

2 Comments

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 :)
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

6 Comments

Did you read the question? The link you provided was already mentioned.
@Lix Obviously not! Woops
yes that is what I am trying to achieve but I dont seem to be able to find the correct extension
@Lix Let me try and redeem myself.
@rig - if you want more info from the OP, you should do so in the form of comments. Please don't use answers to request more information. Note the text on the button - "Post Your Answer"
|

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.