Manikandan Thangaraj
Manikandan Thangaraj

Reputation: 1594

Fatal error: Class 'Mongo' not found in xampp

I'm using Windows 7 64 bit with XAMPP for Windows and can't seem to find the solution to the issue with the installation. I have gone through the Windows and PHP driver installation guides at MongoDB.

From PHP info my environment specs: XAMPP 1.7.4 PHP: 5.3.3 Apache 2.0 Handler

Does anyone have an idea how to finish the installation? I have read tons of peoples comments and tried different troubleshooting and workarounds but nothing worked so far for me.

I am doing the following steps:

  1. Downloading the drivers from the official site
  2. Stopping all services
  3. Updating the PHP.ini
  4. Restarting all services

Its showing :

Fatal error: Class 'Mongo' not found in G:\Project\xampp\htdocs\Mongo\mongo.php on line 2

Anyone can solve the problem .

Upvotes: 3

Views: 10170

Answers (3)

Radmation
Radmation

Reputation: 1534

See this answer, it helped me alot.

PHP MongoDB: Fatal error: Class 'MongoClient' not found

Apparently the MongoClient Class has been deprecated so the old code won't work. I have been trying to follow along tutorials -> and they use the new MongoClient() code, but because I am running php version 7 and the corresponding mongo db dll, this code won't work.

Time to find an updated tutorial.

Upvotes: 0

jacksonbenete
jacksonbenete

Reputation: 159

I know it's really old, sorry for revive, I'm only reviving because it help me to think and to solve my problem in WAMP.

To put everything to work you need to set the mongo program (not mongod) in the system variable PATH, like you do when you installing Java.

If you mongo program are in "C:\data\mongodb\bin" you open the PATH variable, and in the end, put a semicolon the folder with mongo, like: " ;C:\data\mongodb\bin ".

Open you cmd and try to run C:\Users\Yourname>mongo If it runs, you sucessfully "installed" mongo, know you only need to update the php.ini and restart xampp or wamp. Make sure you have put the dll driver in the EXT folder of PHP install. "C:\wamp\bin\php\php5.4.3\ext" for WAMP.

Sorry bad English, I'm only answering because I have the same problem and it help me.

Upvotes: 1

AD7six
AD7six

Reputation: 66298

You don't have the mongo extension loaded.

Have you already followed the installation instructions to the letter? Do you already have mongodb itself installed?

If you can't connect to mongo at all (by typing mongo in a dos prompt) - you need to address that first.

If you can connect to mongo but not via php, there will be a step you've missed, but most likely:

  • open your php.ini file
  • ensure it has extension=php_mongo.dll in it (or in the relevant conf file)
  • restart apache
  • try again

Upvotes: 2

Related Questions