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

BMS51's avatar
Level 1

Laravel Multi-tenancy approach advice.

Hello all,

I'm currenly planning on creating a SaaS project in Laravel in combination with the following packages: Laravel Fortify, Sanctum and Spatie's Multi-tenancy https://spatie.be/docs/laravel-multitenancy/v2/introduction.

I'm currently trying to wrap my head around a few points and could use some insights or advice. there is a landlord database that links a subdomain to a database and contains some roles and permissions for tenant apps. (some extra tables might be added over time). Each tenant has it's own database and subdomain with a login system.

The idea would be to manage the landlord data from the Admin application and retreive the info in the tenant application. (access throught the landlord database).

Most solutions out there tend to weave the landlord application inside the rest of the saas package which is easier to maintain but with some limitations like: Both apps must live on the same domain and share some common routes. Some conflicts might occure with Laravel Fortify routes and other package configurations.

Because of some complications i was thinking about creating a separate Laravel Project to manage the landlord database. But this also has a few downsides. For example both applications have shared models like tenant settings ( link domain -> database), roles and permissions for tenant apps, an both applications have a shared database (landlord). This is a bit harder to manage in 2 applications. Creating a package for the models and using it in both apps reduces the chances of model mismatches, but i don't know if this is a good approach. And also the APP_KEY issue if some encryption is required (for example contact person's email address or sensitive data) The Admin App should have a "Shared APP_KEY".

But it also has some advantages like launching a copy SaaS app on a different server can be connected by adding a new database connection to the admin application

Currently doubting myself if it's considered a bad practice / bad design to have to have a separate package to control the Landlord database and another on to read it.

For this reason i'm reaching out to get some advice or thoughts on this approach. All feedback is welcome and greatly appreciated

Thank you for taking your time to read this and sorry if it's a bit chaotic i'm having trouble translating my toughts into words ;)

Greets, Bart

0 likes
7 replies
BMS51's avatar
Level 1

Hi @automica,

Thank for the videos I'll surely check them out but unfortunately I can't use a single database approach due to some legal aspects. Most tenant databases will be on separate servers and that is something that I cannot change :(. But I will surely check these videos out!

bugsysha's avatar

Most tenant databases will be on separate servers

So does that mean that you will have a server per tenant?

AlexElementarteilchen's avatar

Hi,

you could take a look at https://tenancyforlaravel.com

We've been using it for some months now and it works well. The documentation is ok but sometimes could be more in depth

I find myself going through the code a lot because I don't really understand how things work or where to hook into the code. But once you understand the design and principles behind it, it again works well. I just wish it were explained better in the documentation.

BMS51's avatar
Level 1

Thanks for the recommendation

hamoood8898's avatar

@AlexElementarteilchen Hello Alex, I have used the same library, I am following the original structure and I don't have any special modifications, however caching is not working, do you know how to use it ? Like normal caching is not working, no other caching is been created, locally the app is working but when I push it in azure devops it is not working due to caching issue.

Please or to participate in this conversation.