I have a simple Symfony2 app that needs to connect to a particular database based on the subdomain. Database names are the same as subdomain names.
Domain: alpha.example.com
- DB name: alpha
Domain: beta.example.com
- DB name: beta
The most simple way to achieve this, as I think of it, is to pass current subdomain into the config.yml
file
#config.yml
doctrine:
dbal:
driver: "%database_driver%"
host: "%database_host%"
port: "%database_port%"
dbname: "current-subdomain-name-here"
user: "%database_user%"
password: "%database_password%"
The question is how to pass & access current subdomain name in config.yml
?