I just can't seem to find any clear instructions on how exactly you do that for PHP 7 running on a machine with Windows 7 installed. I tried a couple of online tutorials, but nothing seems to have worked out for me so far. It's possible that some of you may have had an experience similar to mine and it would be absolutely wonderful if you could share that experience with me: specifically, what exactly you did in order to to get this issue resolved.
Install MongoDB. Click here for instructions. Install MongoDB driver for PHP. Check your PHP version using phpinfo. Click here for instructions. PECL has a collection of DLL files for different versions, architecture and thread safety. Choose the one matching your PHP installation. In this example, the PHP installation is 5.6.17, 64 bit, Thread Safe (TS).
Here's what I did:
I downloaded the latest dll library for PHP 7 (mongodb-1.1.2.tgz) from here: PECL :: Package :: mongodb :: 1.1.2, placed the file php_mongodb.dll from the archive into the ext directory where I keep my PHP installation, added the line extension=php_mongodb.dll to the php.ini file (after all these steps, Apache was restarted, of course). The section for mongodb does show up as a result of running the phpinfo() function:
And now I'm trying to run this simple script:
And what I get back is the following error (I have broken the lines a little bit for better readability):
user4087080
1 Answer
MongoDB offers its own driver, with installation instructions on how to set it up, after which you'll have to use the the MongoDB Driver API, rather than the now obsolete MongoClient way of connecting. If
phpinfo()
shows the mongodb extension working, then you should be able to connect to it using the updated syntax:Mike 'Pomax' KamermansMike 'Pomax' Kamermans