1

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?

Rawelja
  • 109
  • 9
  • 2
    Rawelja, 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 Answers1

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']);