The recommended protocol for connection DSNs in some cloud providers is: mongodb+srv
This is failing with an exception that a default database can not be found.
After setting the default database maually I am getting the following issue:
MongoDB\Driver\Exception\InvalidArgumentException: Failed to parse MongoDB URI: 'mongodb+srv://user:password@host/database'.
Invalid URI Schema, expecting 'mongodb://'. in /var/www/html/web/vendor/yiisoft/yii2-mongodb/src/Connection.php:356
I am considering this a bug, as the official MongoDB connection library supports this and it's highly logical for this to be a thin wrapper around it. See PHP example here:
Temporary workaround for anyone else experiencing this issue is to change it to:
if (preg_match('/^mongodb(:|\+srv:)\\/\\/.+\\/([^?&]+)/s', $this->dsn, $matches)) {
https://github.com/yiisoft/yii2-mongodb/blob/837c14c8a38055cd97d6f8b551eef27616f3c8c5/src/Connection.php#L203
The recommended protocol for connection DSNs in some cloud providers is:
mongodb+srv
This is failing with an exception that a default database can not be found.After setting the default database maually I am getting the following issue:
I am considering this a bug, as the official MongoDB connection library supports this and it's highly logical for this to be a thin wrapper around it. See PHP example here: