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

vincent15000's avatar

Multi-tenancy : what do you suggest me ?

Hello,

I search for a good package to write a multitenancy application.

And I have found these packages.

https://tenancyforlaravel.com/

https://tenancy.dev/

https://spatie.be/docs/laravel-multitenancy

Do you know these packages ? Which one would you suggest me ?

I have also followed the series on Laracast.

https://laracasts.com/series/multitenancy-in-practice/

It seems to be interesting to write my own tenancy logic.

Furthermore what parameters are to be taken into account to choose if I need a single or multi database tenancy application ?

What I absolutely need is that all users are in a central database.

  • because each user can work with several tenants. How can I explain ? a user is a freelance who works for several companies and he has to see some datas shared by these companies, but only if he works for these companies.

  • and each personal dashboard (for each user) will show all its missions from each tenant.

With theses contraints, is it better to have a single database ? I think yes. But perhaps it's possible to do another way ?

Thanks a lot for all your suggestions.

V

0 likes
4 replies
jlrdw's avatar

If each client has different data I would go with separate database.

But if a SaaS type like an Accounting app where data is the same, then one database.

You use database session and probably load balancing. The database session allows for login from a central database.

Also put this into google:

site:laracasts.com Multi-tenancy

or

site:laracasts.com multi tenant

And go over some ideas on good past post.

1 like
vincent15000's avatar

@jlrdw Thank you.

Hmmm ... Having separate databases is a good idea if I need to retrieve all missions from all databases at the same time for one user ?

I give an example.

users : A, B, C, D

companies : a, b, c, d

The missions belong to the companies. For example company b has 3 missions and company d has 9 missions.

User A will work with the companies b and d. He needs to see the missions for companies b and d.

Can this work with separate databases ?

jlrdw's avatar
jlrdw
Best Answer
Level 75

@vincent15000 from your description I suggest a single database.

Also this sounds more like a job board, does it even need multi tenant?

1 like
vincent15000's avatar

@jlrdw Perhaps it doesn't need multi tenancy logic.

Well ... the tenants will have to manage and access their own datas.

The users will have to fill some forms to complete the missions for all companies for which they will work.

It's for training companies. The trainers are freelancers and can work for multiple training companies. The students will have to complete a satisfaction quiz after each training. And each trainer will have to write a synthesis of the students' responses for each training. And the he need to access all quiz responses for all his trainings for all companies. Then the training companies can immediately display the results of the quiz and the synthesis written by the trainer. Furthermore the trainer will have to write some informations like the number of students presents/absents, ...

Sorry it's not so easy for me to explain this in details in english.

Please or to participate in this conversation.