0

I have run into following issue. I have a Symfony 2.1 Application. It runs as two independent instances for two independent customers. The source code is exactly the same. Only the databases are different. Is there any possibility, to configure it like that: Only one instance of symfony and different databases depending from domaint. So Customer A will enter address - customerA.com and it loads application with DatabaseA, and customer B enters address customerB.com and it loads application with DatabaseB. Is this possible? If yes, how to do it?

I run Symfony with Doctrine 2 and MySQL.

kathrine0
  • 181
  • 2
  • 4
  • 2
    possible duplicate of [symfony2 dynamic database connection using doctrine](http://stackoverflow.com/questions/20442201/symfony2-dynamic-database-connection-using-doctrine) – COil Sep 23 '14 at 09:23

1 Answers1

1

This is actually possible. Check out this answer by Wouter J about Compiler passes (Also the linked blog post). Basically it allows you to change the state of any controller right before it is frozen. You could use this to update your doctrine connection parameters or modify the connection.

Last but not least you could also go with a simple onKernelRequest event. Read more about it here.

Community
  • 1
  • 1
ferdynator
  • 6,245
  • 3
  • 27
  • 56