Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Rabie's avatar
Level 9

Laravel Multi-tenant / subdmain / multi-database approach

Best way to build a Laravel Multi-tenant Saas application with subdomain for each tenant and mutli-database approch? Anyone who can give us some hints please thanks

0 likes
5 replies
BGWeb's avatar

I wouldn't say that I am adept at MTA (multi-tenant architecture) but I may be able to provide some resources/information to help you get started.

First, I would take a look at the hyn-tenancy package which can be found here https://laravel-tenancy.com/ They also have a decent community on Discord where you can usually find help/advice.

Second, keep in mind, there are multiple ways to develop SaaS/multi-tenant applications and it is not necessarily a straightforward or easy process.

The basic concept is that you will have databases for each tenant and there will need to be a connection for the tenant. As far as using subdomains is concerned, I would guess this is more of a routing or server configuration issue.

Good luck!

colaba's avatar

@BGWEB - Hi BGWEB - just to hijack the thread slightly, is the use case for MTA for databases where clients insist on having their own database for security reasons?

Rabie's avatar
Level 9

@BGWEB - Hi Thanks for your help, through the tenancy package it would be easier for me. As the concept is required by client. I will dig more into how the package work and find a way out ?

BGWeb's avatar

@colaba @rabie I don't know that security would be a primary reason for implementing a MTA; application security is typically agnostic to the particular architecture pattern. For instance, securing your code and/or database should not depend on the way the application is built.

The primary advantage to MTA is scalability. As your application grows and additional tenants are brought on board, it is easier to scale out (horizontally) as opposed to stacking additional databases on top of each other. Further more, this can help improve the performance of the application. And although MTA is inherently more complex to implement and maintain, it will reduce release management in the long run.

See this article for more information.

@rabie If my response helped you, please select it for the best answer.

Thanks!

Please or to participate in this conversation.