7

I am trying to install the mongoDB driver for PHP 7.2.3 x86. I installed the PHP 7.2 Non Thread Safe driver here: https://pecl.php.net/package/mongodb/1.4.2/windows

I have put the mongodb.dll file in the php/ext and put ;extension=mongodb in the php.init file under "Dynamic Extensions".

When I go to my phpinfo() mongo doesn't show up. Running the composer require jenssegers/mongodb command just says: "Unable to load dynamic library 'mongodb'..."

How do I fix this? (I am using xampp)

Ttech
  • 187
  • 1
  • 1
  • 11
  • @Chris I have tried that several times it doesn't seem to fix it but the ";" does comment it out – Ttech Apr 01 '18 at 12:34

3 Answers3

10

You an install mongoDB driver for PHP v7.2.x to run these commands on ubuntu 16.04

 sudo apt install php7.2-mongodb

Or

sudo apt-get install php7.2-mongodb

if you need to install MongoDB you can follow this https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/

Muzafar Ali
  • 164
  • 1
  • 7
3

I have put the mongodb.dll file in the php/ext and put ";extention=mongodb" in the php.init file under "Dynamic Extensions".

There are several problems here:

  • It should say "extension", not "extention"
  • The ; character comments the line out and should be removed
  • You probably need to include .dll in the extension name

This should work better:

extension=mongodb.dll
Chris
  • 93,263
  • 50
  • 204
  • 189
  • Thx for pointing out the typo, luckily I only mad it here. The ";" does indeed comment it out. And in the recent php.ini files the .dll doesn't have to be added anymore. Thanks for the answer! – Ttech Apr 01 '18 at 12:52
3

I have fixed the problem here is what I did: First, check the PHP version by making a php file with:

<?php
phpinfo();

I have PHP version 7.2.3 x86

Go to this website and pick the upload, click on DLL: https://pecl.php.net/package/mongodb/1.4.2/windows

On the bottom, you will see all PHP versions with an x64 and x86 version. If you are running it as an Apache module pick the Thread Safe version.

Copy the php_mongodb.dll file in your php/ext directory. Go to the php.ini file and open it in notepad or what you prefer. Scroll down to Dynamic Extensions and add the following: extension=php_mongodb Do not put a ; this will comment the line.

Restart your Apache and check by running the PHP file you made in the beginning or checking in your terminal with: php --ini

Ttech
  • 187
  • 1
  • 1
  • 11
  • Dont forget to remove the file with `phpinfo()` in it before publishing your code, it's .. how do I put it a huge security concern. – ArtisticPhoenix Apr 01 '18 at 12:51