Skip to content

Ideal setup for a SaaS Multi Tenant System #37

Answered by RamyHakam
MarvinS1991 asked this question in Q&A
Discussion options

You must be logged in to vote

Hi Marvin,

Thank you for your question and for your kind words about the Multi-Tenancy Bundle.

To answer your question, yes, it is possible to centralize the tenant switch event (SwitchDbEvent) instead of dispatching it everywhere you need to create, edit, or delete tenant-specific entities. A common approach is to automatically switch the entity manager to the correct tenant database after a successful login or another key event, like when a user session starts

In this scenario, you can listen to Symfony events such as security.interactive_login or kernel.request to dispatch the SwitchDbEvent with the appropriate tenant identifier. This way, whenever a user logs in or starts a new sessio…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@MarvinS1991
Comment options

Answer selected by MarvinS1991
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants