In this post I will show you how to configure PHP 7.3.5 and MongoDB 4.0.10 in Windows operating system. In my previous tutorial I had shown how to configure PHP 7.2.1 and MongoDB 3.6.4.
Apache 2.4, PHP 7.3.5, MongoDB 4.0.10
Go through the below steps in order to configure PHP 7.3.5 and MongoDB 4.0.10 in Windows.
Downloading MongoDB Driver
Download MongoDB driver compatible with PHP 7.3.5. So you need to use MongoDB driver 1.6.0-alpha2.
Make sure you download the Tread-Safe version according to your operating system (32 bit or 64 bit).
I have chosen here 7.3 Thread Safe (TS) x64 as my operating system is 64 bit.
Copying MongoDB Driver
Now extract the downloaded MongoDB driver and copy to your PHP installation directory.
Let’s say your PHP installation root directory is C:\php-7.3.5, so put your driver file
php_mongodb.dll into C:\php-7.3.5\ext directory.
Configuring PHP ini
Now open PHP default configuration file C:\php-7.3.5\php.ini file and add below entry to this file.
Verifying PHP MongoDB Configurations
Create a phpinfo.php file under htdocs folder of Apache server and put below source code into it.
<?php phpinfo(); ?>
Restart your Apache HTTP server and run the above php file in browser ( http://localhost/phpinfo.php ), you should see the below output for MongoDB server.
Testing PHP and MongoDB Configurations
Create a PHP file php-mongo.php file under htdocs folder of Apache server with below source code.
<?php // Configuration $dbhost = 'localhost'; $dbport = '27017'; $conn = new MongoDB\Driver\Manager("mongodb://$dbhost:$dbport"); print_r($conn); ?>
Now run the above file in browser (http://localhost/php-mongo.php), you will get below output:
MongoDB\Driver\Manager Object ( [uri] => mongodb://localhost:27017 [cluster] => Array ( ) )
Hope you got an idea how to configure PHP 7.3.5 and MongoDB 4.0.10 in Windows operating system.
Thanks for reading.
1 thought on “Configure PHP 7.3.5 and MongoDB 4.0.10”
How to install MongoDB service in Docker image php:7.3
Do you have any tips?