phpinfo:
PHP Version 7.2.24-0ubuntu0.18.04.17
|MongoDB extension version|1.3.4|
|MongoDB extension stability|stable|
|libbson bundled version|1.8.2|
|libmongoc bundled version|1.8.2|
|libmongoc SSL|enabled|
|libmongoc SSL library|OpenSSL|
|libmongoc crypto|enabled|
|libmongoc crypto library|libcrypto|
|libmongoc crypto system profile|disabled|
|libmongoc SASL|enabled|
I try to connect with this code:
try {
$mdbserver = 'foo.bar.mongodb.net';
$user = 'username';
$pw = 'password';
$client = new MongoDB\Client('mongodb+srv://'.$user.':'.$pw.'@'.$mdbserver.'/?retryWrites=true&w=majority');
echo(MSG_CLIENT_SUCCESS);
}
catch (Throwable $e) {
// catch throwables when the connection is not a success
echo "Captured Throwable for connection : " . $e->getMessage() . PHP_EOL;
}
but I get this error:
Failed to parse MongoDB URI: 'mongodb+srv://username:password@foo.bar.mongodb.net/?retryWrites=true&w=majority'. Invalid URI Schema, expecting 'mongodb://'.