Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing mongoDB driver php 7.2.3

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)

like image 832
Hoxlegion Avatar asked Apr 01 '18 12:04

Hoxlegion


People also ask

What is a MongoDB driver?

The official MongoDB Node. js driver allows Node. js applications to connect to MongoDB and work with data. The driver features an asynchronous API which allows you to interact with MongoDB using Promises or via traditional callbacks.

Can I use MongoDB with PHP?

You can add the driver to your application to work with MongoDB in PHP. The MongoDB PHP Driver consists of the two following components: The extension , which provides a low-level API and mainly serves to integrate libmongoc and libbson with PHP.

How to install MongoDB in PHP?

MongoDB is distributed in nature. As MongoDB is open-source in nature, it is free to use & easy to install. Step 1: For downloading PHP Drivers, browse the official website using any browser. There are many versions of PHP drivers of MongoDB that can be found. It is advisable not to go for alpha or beta versions.

What are the components of the MongoDB PHP driver?

The MongoDB PHP Driver consists of the two following components: The extension, which provides a low-level API and mainly serves to integrate libmongoc and libbson with PHP. The library, which provides a high-level API for working with MongoDB databases consistent with other MongoDB language drivers.

What is the MongoDB extension?

The extension provides a low-level API and mainly serves to integrate libmongoc and libbson with PHP. While it is possible to use the extension alone, users are strongly encouraged to use the extension and library together. The library provides a high-level API consistent with other MongoDB language drivers.

How do I install the XAMPP driver?

Linux, Unix, and macOS users may run the following command to install the driver: If your system has multiple version of PHP installed (e.g. macOS default, Homebrew, » XAMPP ), note that each version of PHP has its own pecl command and php.ini file (s). Additionally, each PHP environments (e.g. CLI, web) may use separate php.ini files.


Video Answer


3 Answers

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/

like image 161
Muzafar Ali Avatar answered Oct 11 '22 16:10

Muzafar Ali


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
like image 36
Chris Avatar answered Oct 11 '22 14:10

Chris


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

like image 3
Hoxlegion Avatar answered Oct 11 '22 16:10

Hoxlegion