Install MongoDB PHP Extension on window

Source: Internet
Author: User
Tags install mongodb mongodb driver php mongodb

1. Download

Pre-compiled PHP MongoDB driver binaries (: Php_mongo) for the Windows platform have been provided on GitHub and can be downloaded in a version corresponding to PHP in the real world. I built the environment in PHP version 5.6.11, so the download PHP mongodb drive binary package for Php_mongo-1.6.8.zip.


File decompression after a lot of different file name DLL files, you need to pay attention to the following issues:
The ' thread safe ' (thread safety) is on PHP that runs on Apache, and if you run PHP in CGI mode, select non-thread safe mode (' non-thread safe ').
The VC9 is running on the IIS server.

I chose Php_mongo-1.6.8-5.6-vc11.dll, a thread-safe PHP version of 5.6, to change the file name to Php_mongo.dll and add it to your PHP extension directory (EXT). The ext directory is usually in the Ext directory under the PHP installation directory.

2. Configuration

Open the PHP configuration file php.ini Add the following configuration:

Extension=php_mongo.dll

3. Testing

Restart the server, access the phpinfo through the browser, if the installation is successful, you will see the following types of information: 4\

4. Simple Application

PHP Code:

<?php//mongodb is installed on this machine, the port used is 27017. $client = new Mongoclient ("mongodb://127.0.0.1:27017");//Select the database and specify the data table. $collection = $client->test->persons;// Insert Data $array = Array (            ' name ' = ' = ' Liuruiqun ',            ' age ' =>25,            ' address ' =>array (                        ' province ' = ') Sichuang ',                        ' city ' = ' Chengdu '                                              )        ; $ret = $collection->insert ($array);//query data $res = $collection- >findone ();//Print Data var_dump ($res);

Operation Result:



Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Install MongoDB PHP Extension on window

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.