Cygnus
Cygnus

Reputation: 3330

PHP : Mongo class not found

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.

Upvotes: 0

Views: 2961

Answers (3)

Sayf Roumane
Sayf Roumane

Reputation: 1

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;

Upvotes: 0

Cygnus
Cygnus

Reputation: 3330

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 !!

Upvotes: 0

Mark Hillick
Mark Hillick

Reputation: 6973

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.

Upvotes: 0

Related Questions