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