Install php mongodb extension windows

Precompiled binaries for each release are available from » PECL for a variety of combinations of versions, thread safety, and VC libraries. Extract the archive and put php_mongodb.dll in your PHP extension directory ("ext" by default).

Add the following line to the php.ini file for each environment in which you intend to use the driver:

extension=php_mongodb.dll

Note: Additional DLL dependencies for Windows Users

In order for this extension to work, there are DLL files that must be available to the Windows system PATH. For information on how to do this, see the FAQ entitled "How do I add my PHP directory to the PATH on Windows". Although copying DLL files from the PHP folder into the Windows system directory also works (because the system directory is by default in the system's PATH), this is not recommended. This extension requires the following files to be in the PATH: libsasl.dll

luchontandil3 at gmail dot com

2 years ago

Try using:

extension=php_mongodb.dll

instead and restarting the xammp server for php
also download the correct .dll for your version of php

you can check your version of php with index.php and inside adding

phpinfo();
>

Xylon Reyes

6 years ago

With the newer version of MongoDB, this should be...

extension=php_mongodb.dll

(the filename of the latest stable release at PECL)

Official MongoDB library are available at GitHub as well as its documentation.

Precompiled binaries are also available at GitHub for the legacy and the newer version.

I followed the steps mentioned here https://www.youtube.com/watch?v=9gEPiIoAHo8.

I downloaded the latest stable version of it here https://pecl.php.net/package/mongodb which is 1.3.4. Extracted the php_mongodb.dll and placed it in the ext in my xampp directory. Modified the php.ini and added extension=php_mongodb.dll. Downloaded the composer but just when the composer installer does its work, it gives me the error.

I tried the x64 TS (I checked my phpinfo and its thread safe) because my laptop is 64 bit but it gives me an error

Program Output: PHP Warning: PHP Startup: Unable to load dynamic library 'C:\xampp\php\ext\php_mongodb.dll' - %1 is not a valid Win32 application. in Unknown on line 0

Tried the x84 as well (i know it wont work but i tried nontheless) and it gives me an error

The ordinal 4694 could not be located in the dynamic link library C:\xampp\php\ext\php_mongodb.dll

Followed by another pop-up after the mentioned error above

PHP Startup: Unable to load dynamic library C:\xampp\php\ext\php_mongodb.dll - The operating system cannot run %1

My PHP Version is PHP Version 5.6.3

Xampp Version v3.2.1 Compiled May 7th 2013

I tried other mongoDB php driver php_mongo.dll, it works fine and is loaded when i do php_info. I wanted to use the php_mongodb.dll since the other is depreciated.

Learn how to install MongoDB on Windows OS and configure with PHP on XAMPP.

There are a couple of tutorials out there already, but neither of them helped me set everything up 100%. Some of them are missing key explanations, some of them are a bit old. My tutorial presumes you know your way around XAMPP on Windows and you have it installed already.

Here’s how to install MongoDB on your local Windows machine with XAMPP in 5 easy steps:

Step 1. Download mongo driver

To download mongo driver for Windows visit pecl.php.net

Download the latest stable release by clicking on the DLL link. I used the latest stable release at the time, 2017-05-04, version 1.2.9.

Install php mongodb extension windows

On the next page there is a DLL list. It is vital to pick the right version. You need to pick depending on three things:

  • the PHP version that is installed with your XAMPP
  • Architecture x86 or x64
  • Whether Thread Safety is enabled or disabled

Here’s where to find out that information:

  1. Start XAMPP
  2. Navigate to the XAMPP dashboard via Internet browser (tipically at http://localhost)
  3. Click the PHPinfo in the top menu
    Install php mongodb extension windows
  4. There, in the new tab you will see the table with the necessary information. At the top, you will see PHP version, in my case it was 7.0.13
    Install php mongodb extension windows

Below that, in the table, you will see list of other information. You need to find the value for the Architecture (x86 or x64) and Thread Safety (enabled or disabled).

Finally, you can choose a proper DLL to download.
In my case, I had:

  • PHP version 7.0.13
  • Architecture x86
  • Thread Safety enabled

When Thread Safety is enabled, you need to download Thread Safe (TS) version. So I downloaded file: 7.0 Thread Safe (TS) x86

Install php mongodb extension windows

Step 2. Unzip downloaded mongo driver version and copy .dll file to XAMPP

After successful download, unzip and find the .dll file. Copy it to ext directory of your XAMPP installation. If you installed XAMPP to C drive, full path to the ext folder would be C:\xampp\php\ext

Step 3. Register mongo .dll file within php.ini

Add following line into php.ini file:

extension=php_mongodb.dll

If your .dll file name is different, it’s ok, just make sure you call it like that within php.ini file. For example, if you added a file with a name of php_mongo.dll in the ext folder, you need to put that in the php.ini file.

Step 4. Restart XAMPP and refresh phpinfo.php page

When you restart XAMPP and refresh the phpinfo page, something like this should appear when you CTRL+F and type mongo:

Install php mongodb extension windows

If you don’t see that on your phpinfo page, you did something wrong so try to go back through previous steps.

a) Download latest MongoDB server version.
b) Choose custom setup type and install in the C:\mongodb folder.
c) Then create db folder within data folder on the C drive – C:\data\db
d) Start MongoDB by executing the following command in the CMD: C:\mongodb\bin\mongod.exe

That is it, you successfully installed MongoDB on Windows and configured it in XAMPP!
Just in case you need extra help with step 5, here is the entire process explained with images.

Step 6. Download and install RoboMongo

As an extra step I would recommend installing MongoDB management tool, such as RoboMongo, (it’s called Robo 3T now)  to easily manage MongoDB on your machine. Just create connection and you are set to go.

Conclusion and additional resources

Hope you found this tutorial useful in the process of installing and configuring MongoDB on your Windows machine with XAMPP.

For the next step, I recommend checking out the following MongoDB online courses on Pluralsight:

Introduction to MongoDB

MongoDB Administration

These fantastic courses by Nuri Halperin helped me to learn a lot more about MongoDB.

How use MongoDB with PHP on Windows?

Get started with MongoDB and PHP with XAMPP on Windows.
Copy the extracted php_mongodb. dll file into :\xampp\php\ext folder..
Open XAMPP php. ini and add the line: extension=php_mongodb. dll..
Restart the Apache server in XAMPP. You're good to go..

How do I install or enable PHP's MongoDB extension?

Installing the MongoDB PHP Library.
$ composer require mongodb/mongodb..
Using version ^1.8 for mongodb/mongodb..
./ composer. ... .
Running composer update mongodb/mongodb..
Loading composer repositories with package information..
Updating dependencies..
Lock file operations: 4 installs, 0 updates, 0 removals..
Writing lock file..

Can PHP connect to MongoDB?

MongoDB provides PHP drivers, allowing us to connect and manage a MongoDB instance from code.

How add MongoDB to xampp?

Installing MongoDB in XAMPP Windows.
Install mongoDB in the following path: c:/mongodb..
Go to your c:/ drive then create a new folder “data“, inside it create another folder “db“.
Start MongoDB in your command prompt by executing the following command: C:\mongodb\bin\mongod.exe..