Install and Configure MongoDB with PHP on Windows
#MongoDB #PHP #Windows
Full steps can be found at https://i12bretro.github.io/tutorials/0392.html
--------------------------------------------------------------------
Adding PHP Support for MongoDB
--------------------------------------------------------------------
01. Open Windows Explorer and navigate to the PHP installation directory
02. Hold the SHIFT key and right click in the white space ≫ Open PowerShell window here...
03. Run the following command to output the PHP version information
.\php.exe -v
04. Note the architecture (x86 or x64) and the PHP version
05. Open a web browser and navigate to the MongoDB PHP driver page https://pecl.php.net/package/mongodb
06. Click the Windows DLL link
07. Select either the x86 or x64 to match the PHP installation. If using PHP with Apache or nginx download the Thread Safe version. If using PHP for IIS, download the Non-Thread Safe version
08. Extract the downloaded .zip file
09. Copy the .dll file from the extracted folder to the PHP installation /ext directory
10. Find php.ini inside the PHP installation directory and edit it in a text editor
11. Search for ;extension=
12. At the bottom of the list of extensions, add the following line
extension=mongodb
13. Restart the web server to apply the change
--------------------------------------------------------------------
Installing MongoDB on Windows
--------------------------------------------------------------------
01. Download MongoDB Community Server https://www.mongodb.com/try/download/community
02. Navigate to the Downloads directory ≫ Launch the MongoDB .msi installer
03. Step through the installer accepting all the defaults
--------------------------------------------------------------------
Testing PHP and MongoDB
--------------------------------------------------------------------
01. Download the mongodb_test.php https://raw.githubusercontent.com/i12bretro/tutorials/main/_Downloads/mongodb_test.php
02. Save mongodb_test.php on the root of the web server
03. Open a web browser and navigate to http://DNSorIP/mongodb_test.php
04. The page will create a new database called phpDemo, a collection named states, write some rows and then read them back and display them in a table
--------------------------------------------------------------------
Install MongoDB Compass (Optional)
--------------------------------------------------------------------
01. Open a web browser and navigate to the MongoDB Compass GitHub latest release https://github.com/mongodb-js/compass/releases/latest/
02. Download the win32-x64.zip file
03. Extract the downloaded .zip file
04. Move the extracted files to a folder where it will run from permanently (ie C:\Program Files\MongoDBCompass\)
05. Run MongoDBCompass.exe
06. Once the application loads, click the green Connect button to connect to the locally running MongoDB instance
For more information on MongoDB CRUD operations with PHP check out https://roytuts.com/mongodb-php-7-crud-example/
### Connect with me and others ###
★ Discord: https://discord.com/invite/EzenvmSHW8
★ Reddit: https://reddit.com/r/i12bretro
★ Twitter: https://twitter.com/i12bretro