Search code examples
phpmongodbwamp

Fatal error: Class 'Mongo' not found in


I need to use Mongodb in my PHP script.

So I have installed php_mongodb.dll from php_mongodb-1.2.5-5.6-ts-vc11-x64.zip into "C:\wamp64\bin\php\php5.6.25\ext\". I have added extension.dll in php.ini.

When I run php.exe, there is nothing wrong, any warning... But Mongodb doesn't appear in the list of php extensions (phpinfo()).

In addition, my index.php returns "Fatal error: Class 'Mongo' not found in C:\wamp64\www\scripts\index.php on line 47". The line 47 : $con = new Mongo(); # localhost:27017

  • Version Apache :2.4.23
  • Version de PHP :5.6.25
  • OS : Windows 10
  • Wamp : Version 3.0.6 - 64bit

I have already tried php_mongodb.dll or php_mongo.dll, different other versions... But now, I have any idea.

If someone has solution to propose, he will be welcome. Thank you in advance.


Solution

  • Finally, I found a solution... The right dll !

    In fact, I must use MongoDB PHP Driver on Windows. Then add extension=php_mongodb.dll into php.ini. And download the corresponding file from mongodb 1.2.5, in this case 5.6 Thread Safe (TS) x64.

    php.exe shows no warning and the line 47 ($con = new MongoDB\Driver\Manager("mongodb://localhost:27017"); # localhost:27017) works correctly.

    Don't forget to restart services.

    Hopefully this solution will serve...