2

I'm trying to load the MongoDb extension for php on a Windows 7 64 bit PC, running XAMPP with Apache 2.0 and PHP 5.3.5, compiler version VC6. I started out with this tutorial, and have also tried the extensions that the php documentation suggested. MongoDb itself is running fine, and shell commands seem to work.

At the moment I have:

  1. Added extension=php_mongo.dll to my php.ini file.
  2. Put the VC6 version of php_mongo.dll (from the following download page, suggested by the PHP documentation) in the php/ext folder.
  3. Restarted my Apache server.

I have also tried php_mongo.dll files form Stealth's github, but they didn't seem to work either.

When restarting Apache, I don't get any errors, but I can't find anything on MongoDb in phpinfo(), and the Mongo class is not recognised either.

Any ideas of what might be wrong? Let me know if you need more info.

4
  • Can you tell us what extension folder php has registered within the phpinfo() output? Commented Jun 6, 2013 at 14:16
  • The extension folder is C:\xampp\php\ext Commented Jun 6, 2013 at 14:33
  • 1
    Which INI file did you modify? And which INI file does phpinfo() tell you it is using? PHP will raise error messages when it cannot load an extension you have specified in the used php.ini file, so you are either suppressing these errors or you are modifying the wrong php.ini Commented Jun 10, 2013 at 21:12
  • I had this same problem, turns out I was enable the extension in wrong ini file, check your phpinfo for which php .ini file is being used. Commented Jun 5, 2016 at 21:00

5 Answers 5

2

The problem might be incorrect version of extension. Try different versions downloaded from here: http://pecl.php.net/package/mongo/1.6.4/windows

Sign up to request clarification or add additional context in comments.

Comments

1

Use Bitnami WAMP Stack instead of XAMPP it comes preloaded php_mongo.dll driver installed and no need to configure php.ini file

There is no official MongoDB Driver released for PHP7. So it would be better to download the recommended PHP version 5.5.30(currently) offered by Bitnami Wamp Stack.

Comments

1

There might be two reasons:

First one is as @Sadd suggested. Your mongodb extension should be loaded after what you have done so its very likely that you have enabled extension in wrong file. And yes, there are two such similar files (named php.ini-development and php.ini-production on windows computers), so make sure to enable it in php.ini file and run the following code echo extension_loaded("mongodb") ? "loaded\n" : "not loaded\n"; and you should see loaded on screen.

If you still don't see it, then the second thing you can do is to check whether the version is right or not. You can check your phpinfo() for your php version and then put the right versioned dll file in ext folder. In this, you can have to check whether your php is ts or nts and second one is whether your php is x64 or x86. I hope you are good to go after one or both of the changes.

Comments

0

This was driving my crazy until I looked closely at my PHP version:

$ php -v
PHP 7.4.1 (cli) (built: Dec 17 2019 19:23:59) ( NTS Visual C++ 2017 x64 )

Notice that it says PHP 7.4.1 and NTS and x64? This means that when I download from PECL, I need version 7.4 Non Thread Safe (NTS) x64 or it won't run correctly.

Comments

0

If the correct version of module is not added, an error is thrown.

[PHP Warning: PHP Startup: Unable to load dynamic library 'php_mongodb.dll' (tried: C:\xampp\php\ext\php_mongodb.dll (The specified module could not be found), C:\xampp\php\ext\php_php_mongodb.dll.dll (The specified module could not be found)) in Unknown on line 0]

When downloading the dll extension from https://pecl.php.net/package/mongodb, make sure that NTS (Non Thread Safe) or TS (Thread Safe) is chosen according to what shown from php -v command.

$ php -v
PHP 8.1.7 (cli) (built: Jun  7 2022 21:45:53) (ZTS Visual C++ 2019 x64)

Although here it shows ZTS, TS version can be used in this case.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.