3

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 .

ajduke
  • 4,991
  • 7
  • 36
  • 56
Manikandan Thangaraj
  • 1,594
  • 8
  • 24
  • 44

3 Answers3

2

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
AD7six
  • 63,116
  • 12
  • 91
  • 123
  • This didn't help resolve the error at all. This is exactly the same as all installation instructions - not very helpful. – Radmation Jun 17 '16 at 18:37
  • 1
    @Radmation the [mongodb extension was created in 2015](https://pecl.php.net/package/mongodb) - the mongo extension, which this answer is relevant to, [preceeded it](https://pecl.php.net/package/mongo). Seems a little odd to downvote an answer for not helping you, when it was written 3 years before the solution and circumstances to your current problem (based on the answer below having changed from mongo to mongodb extensions, and needing to update usage). – AD7six Jun 20 '16 at 10:28
1

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.

jacksonbenete
  • 159
  • 1
  • 9
0

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.

Community
  • 1
  • 1
Radmation
  • 1,486
  • 1
  • 13
  • 30