Closed miljojohn closed 6 years ago
Looking at examples in the documentation your URI looks weird.
Ok this seems like a bug then. At a glance I don't see anything in the bundle that would be prepending URI with additional mongodb://
, can you please share what driver are you using? Is this legacy mongo
or new mongodb
+ adapter?
I am using 3.6 and i am able to connect the mongodb atlas using new MongoDB\Client
$con = new MongoDB\Client("mongodb+srv://testuser:testpassword@cluster0-324234.mongodb.net"); I am attaching the php file which is working perfectly . phpconnection.txt
From symfony i tried with the connection string for 3.4 mongodb version and its working fine.
Thanks a lot.
Ok, found the issue in the adapter, gonna open an issue there and cross reference.
@miljojohn would you mind testing dev-master
of mongo-php-adapter
? I've merged the changes and will tag a new release later today.
@miljojohn the 1.1.5 release of mongo-php-adapter
fixes the handling of mongodb+srv
connection URLs. If the problem persists, please open an issue there. Thanks!
While not good, the error points out that ext-mongodb
was built without SSL support. How did you install the driver?
pecl install mongodb
$ echo "extension=mongodb.so" >> php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"
Installed ext-mongodb using this command and also i am able to connect the atlas server from normal php on the same server. Please refer this code https://github.com/doctrine/DoctrineMongoDBBundle/files/1774462/phpconnection.txt
The exception with message "Cannot create SSL client. SSL is not enabled in this build." originates in phongo_manager_init()
when MONGOC_ENABLE_SSL
is not defined.
In the same file, PHP_MINFO_FUNCTION(mongodb)
also checks whether MONGOC_ENABLE_SSL
is defined to report "libmongoc SSL" for phpinfo()
output.
The formatting of the phpinfo()
output you've shared numerous times in this thread indicates that you obtained it from a CLI process. I'm reasonably certain that if you checked the phpinfo()
output from the same PHP environment that is yielding the "Cannot create SSL client." error, you'd find that "libmongoc SSL" is not enabled.
It's entirely possible to have multiple versions of PHP installed on the same system. This is often the case for MacOS users, where they might have the default version of PHP that ships with MacOS, a version available with MAMP, and/or a PHP runtime installed with Homebrew. In the future, this is all helpful information that you should provide in a support request. AFAIK, you've provided no details whatsoever about your operating system or PHP environment.
pecl install mongodb echo "extension=mongodb.so" >> php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"
The second line in the command above is only adding "extension=mongodb.so" to the INI file used by the php
CLI command. You should understand that each PHP SAPI (e.g. CLI, web) may have its own INI file, which will need "extension=mongodb.so" added to function properly.
I assume you copied that snippet from the PHP library or driver README files. Both of those also link to Installing the MongoDB PHP Driver with PECL on PHP.net, which talks about each PHP environment possibly having its own pecl
command and php.ini
files.
You should confirm exactly which PHP environment is producing this exception, and then walk through installation steps for that exact environment. Assuming that environment has its own pecl
command and php.ini
file, those should be used for installation.
thank you @jmikola . Issue is fixed.
I am trying to use mongodb atlas in my application.I set up my .env file like
> doctrine/mongodb-odm-bundle
MONGODB_URL=mongodb+srv://testuser:yyyyxyxyyx@cluster0-xcz.mongodb.net MONGODB_DB=db_XYZ
< doctrine/mongodb-odm-bundle
But i got one uri parse error. Failed to parse MongoDB URI: 'mongodb://mongodb+srv://xxxxx:yyyyyyyyy@cluster0-xyz.mongodb.net
Please help .