Fatal error: Class 'Mongo' not found in xampp

左心房为你撑大大i 提交于 2019-12-12 15:24:08

问题


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 .


回答1:


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



回答2:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/9724532/fatal-error-class-mongo-not-found-in-xampp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!