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