I want to connect Laravel with DocumentDB from AWS. But i cant find any document or tutorial about this. is there a way to connect DocumentDB at least to Laravel server?
Asked
Active
Viewed 1,677 times
1
-
2Rawelja, you should be able to connect to DocumentDB from Laravel using the same connection string and pre-requisites as MongoDB. Have had a chance to try the steps listed here: https://github.com/jenssegers/laravel-mongodb. Happy to help you with any error/issues you have encountered – meet-bhagdev May 28 '20 at 21:04
1 Answers
1
The documentation provided in AWS docs [for php] didn't work for me, the below connection uri works.
$dbUri = "mongodb://$user:$pass@$host:$port/$db?retryWrites=true&w=majority&authSource=admin
&ssl=true&sslcertificateauthorityfile=$sslFilePath/rds-combined-ca-bundle.pem";
$client = new MongoDB\Client($dbUri,['readPreference' => 'secondaryPreferred']);

Puneet Mishra
- 11
- 2
-
1key difference is `sslcertificateauthorityfile`, usually its `ssl_ca_certs`. – Puneet Mishra Feb 09 '21 at 08:47