0

I am trying to run MongoDB with PHP. I have XAMPP 1.7.7 installed on my machine (Windows XP - 32 bit).

The PHP version is 5.3.8 and Apache version is 2.2.21. I installed the PHP MongoDB drivers as was given on their instructions page. I have the php_mongo.dll from this zip - mongo-1.1.4-php5.3vc9ts ( because i see that Thread Safety is enabled).

However, i always keep getting the message - 'Fatal error: Class 'Mongo' not found' for this code snippet-

$mongo = new Mongo();
$db = $mongo->database_name;

Does anyone know the solution to this ?

Thanks in advance.

Cygnus
  • 3,222
  • 9
  • 35
  • 65
  • 1
    Did you enable this module? Try `phpinfo();` to see is the module has been loaded – ajreal Jun 04 '12 at 09:48
  • No. And yeah, i forgot to mention that too - the module is not being shown as loaded in phpinfo() (called from same script). I have added 'extension=php_mongo.dll' to the php.ini file too. Is there anything else to be done ? – Cygnus Jun 04 '12 at 09:50
  • Have you restarted apache ? Did you put the dll into the path that can be read by apache? – ajreal Jun 04 '12 at 09:54
  • Yeah, i did restart apache. Same error inspite of that. And i have put the dll into C:\xampp\php\ext\ . Is that fine ? – Cygnus Jun 04 '12 at 09:56
  • Enable error logging in php (including start-up errors) and then restart apache and look in the error logs. That might tell you what's going on. – dakdad Jun 04 '12 at 11:34
  • Error logging is on. The log contains the same record - 'Fatal error Class 'Mongo' not found' !! – Cygnus Jun 04 '12 at 12:42

3 Answers3

0

Please see this link - Error installing MongoDb PHP driver with XAMPP on Max OS Lion - I think it's possibly the same issue, though it was on Mac OS whereas you're on Windows.

I believe that you may need to install the xampp "Developer Package", required to build additional php extension.

The "Developer Package" can be found here : http://www.apachefriends.org/en/xampp-windows.html.

Community
  • 1
  • 1
Mark Hillick
  • 6,853
  • 1
  • 19
  • 23
0

Problem solved !! What i did was re-installed Apache and applied the changes. It worked, although i don't know what went wrong in the first place !! Thank you everyone for your help !!

Cygnus
  • 3,222
  • 9
  • 35
  • 65
  • Congrats on the fix! When you are able, please make sure to mark your answer as 'accepted' so that others will be able to learn from your success. Cheers~ – Andrew Kozak Jun 05 '12 at 14:18
0

It's because you forgive something .. Mongo don't understand a class unknow so you have to do that :

$mongo = new MongoClient();
$db = $mongo->database_name;
Gerard de Visser
  • 7,590
  • 9
  • 50
  • 58