platformsh / symfonyflex-bridge

Bridge library for running Symfony Flex on Platform.sh
MIT License
30 stars 15 forks source link

Support multiple database relationships #43

Closed brianV closed 1 year ago

brianV commented 3 years ago

We have a client site on Platform.sh that has two databases - our primary Symfony database, and a legacy Drupal 7 database which is mostly used as a legacy data storage / migration source.

Currently, the Symfony Flex bridge only automatically configures a single database relationship into the DATABASE_URL environment variable.

This PR adds some flexibility - you can now define a DATABASE_RELATIONSHIPS environment variable in your Platform.sh environment that lists one or more database relationships to be configured. If this variable is not provided, the database relationship is still attempted by default, similar to the current behaviour.

Each relationship is then mapped to a <RELATIONSHIP_NAME>_URL environment variable named by taking the relationship name, uppercasing it, and appending _URL'. For example, adatabase_legacyrelationship would be mapped to aDATABASE_LEGACY_URL` environment variable.

I've also included updates to the README to document the added functionality.