I'm aware that there are other questions similar to this one, but none of them have solutions to the exact problem that I'm having.
I've installed the mongodb php driver, added the dll to xampp/htdocs/ext, and editted php.ini to include the new extension. However, when I try to run this php:
<?php
$connection = new MongoDB\Driver\Manager("mongodb://localhost:27017");
$db = $connection->lotus;
$users = $db->users;
$document = array(
"username"=>"firstuser",
"password"=>"firstpass"
);
$users->insert($document);
?>
I get the error: Fatal error: Uncaught Error: Class 'MongoDB\Driver\Manager' not found in C:\xampp\htdocs\testproject\index.php:2 Stack trace: #0 {main} thrown in C:\xampp\htdocs\testproject\index.php on line 2
A post on this same issue says that they confirmed that the extension was loaded using the following code:
echo extension_loaded("mongo") ? "loaded
" : "not loaded
"
However, I always receive "not loaded" as the output. Not sure exactly what I'm doing wrong here. Any ideas?
EDIT
The current php version is 7.2.8. I also found this error message when I checked the php version: PHP Warning: PHP Startup: Unable to load dynamic library 'php_mongodb.dll' (tried: \xampp\php\ext\php_mongodb.dll (%1 is not a valid Win32 application.)
This seems to be the source of the problem.
Solution has been found - see below