Yamen Nassif
Yamen Nassif

Reputation: 2476

Dynamic subdomains with different DBs in symfony

I have a full working symfony project with integrated login/users. now some users -depends on their roles- have the ability to create new 'client(s)'. What i am looking for is with the creation of each new client to have:

  1. New subdomain client.mydomain.com
  2. Same database i have from the project to be copied into a new database with the client name; let's say that my DB is mydb-mydomain so with each new client i need new DB with mydb-clientname
  3. Single login which means the user will login on the mydomain.com and depends on their client(s) will be directed to the client.mydomain.com
  4. each user can have more than one client in this case when a user is logged in the first client is to be chosen to redirect to.

I managed to do the redirection depends on the user client(s) but its virtual since i didn't manage to create new DB/Subdomain for each new client. As for the subdomain my SP have an API to do that which i will simply call and attach the subdomain to the created client. My last problem is how to create new DB and tell the application to use the correct DB connection with different users/subdomains.

Any hitns will be appreciated. googled a bit didnt find any "usefull" hints.

p.s. i am using Symfony 4.0.4

Upvotes: 1

Views: 180

Answers (1)

birkof
birkof

Reputation: 634

You need to design a Multi-Tenancy application & adapt it to work with SF4 (See more info here)

Upvotes: 1

Related Questions