WAMPServer Fatal error: Class 'Mongo' not found

雨燕双飞 提交于 2019-12-12 05:47:54

问题


I'm using a Windows 8 64-bit machine and a 32-bit version of WAMPServer

  • I downloaded the PHP drivers from Github https://github.com/mongodb/mongo-php-driver/downloads
  • Copied the .dll to C:\wamp\bin\php\php5.4.16\ext\
  • Added the line extension=php_mongo.dll to the php.ini file
  • I still get Fatal error: Class 'Mongo' not found

I echoed phpinfo() and the extension has not been loaded - it does not appear

Does anyone know how to fix this?


回答1:


Had the same issue. Below steps solved my issue.

  1. Make sure you have a 32 bit WAMP setup in place. Apparently, there are problems with 64 bit
  2. Get the lates php_mongo driver from https://github.com/mongodb/mongo-php-driver/downloads compatible with your version
  3. Rename it to php_mongo.dll and copy it to php extenstions folder. Default on windows is "ext"
  4. check phpinfo()
  5. Check for Loaded Configuration File variable. It gives you the path from where the php.ini file is read
  6. Add the line extension=php_mongo.dll to the php.ini file in the above path
  7. Restart your services



回答2:


I can't add this as a comments because of low reputation.

Did u restart your server after updating ur php.ini file.




回答3:


Looks like it can't load the Mongo Module.

First You have to download the stable dll zip file. PHP-MONGO

Download the Threaded-version of the module. Copy the dll file and paste it in C:\wamp64\bin\php\php5.6.19\ext (if wamp). then go to your php.ini file and paste the following script: extension=php_mongo.dll in the extensions row.

Note: There shouldn't be a ';' before the extension . Then restart WAMP. In the wamp-php-extension menu you could find the php_mongo. tick mark it. Restart Wamp.

Start mongo and the try executing the following script.

<?php
    if($connection = new mongoClient()){
        echo "Connected Successfully";
     } 
?>`

Note: First start the Mongo server.

For more info: PHP/Mongo Manual

If you have problem in start Mongo then Write the command as follows in your Mongo/bin directory:

mongod --storageEngine=mmapv1 --dbpath [your-path]

your-path= The path you want to save the Databse files. (ex: F:\data\db )

The Mongo sever would be running now. Don't close the cmd.



来源:https://stackoverflow.com/questions/21785995/wampserver-fatal-error-class-mongo-not-found

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