Reputation: 193
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:
extension=php_mongo.dll
to my php.ini
file.php_mongo.dll
(from the following download page, suggested by the PHP documentation) in the php/ext folder.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.
Upvotes: 2
Views: 6150
Reputation: 1
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.
Upvotes: 0
Reputation: 29
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.
Upvotes: 0
Reputation: 21
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.
Upvotes: 1
Reputation: 368
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.
Upvotes: 1
Reputation: 7752
The problem might be incorrect version of extension. Try different versions downloaded from here: http://pecl.php.net/package/mongo/1.6.4/windows
Upvotes: 2