The DoctrineMongoDbBundle documentation is not really clear. The default configuration with a single connection and no authentication works pretty well (as described in the doc), but if we want to work with many authenticated connections, it’s not really easy to setup because the doc does not explain the configuration clearly.
Connection string / server
The server (connection string) section must contain several elements:
- The hostname
- The username
- The password
- The port
An example where:
- john is the username
- doe the password
- mongo the hostname (could be 127.0.0.1)
- 27017 the port
Connections / Managers
- The identifiers for connections and managers must be equal.
- The database configuration must be present in the connections section and in the managers section.
The full minimal configuration with multiple authenticated connections
If you work with docker, and docker-compose you could use this image/configuration:
And create a link with your app container: