RedditPP Mascot

RedditPP

r/laravel • … • u/floppy_dizk

The Laravel tenancy battle going on right now!

There is so much talk about Tenancy nowadays. It's terrific. I've been trying to pick it up for some time now, specifically the 1-app:many-databases approach, and just a few days ago I jumped in again.

My goals were re-realized after watching Mohamed Said's [Multitenancy in Laravel: Migrations, Testing, and switching tenants](https://www.youtube.com/watch?v=592EgykFOz4). Switching to a multi-db approach seemed simple enough. I'd say the tutorial gets you pretty far into the weeds, but it does leave a lot left over to make the application production-ready. So now that I have a better understanding, why not check out a mature/stable tenancy package to see if I can close the gap with what I started?

Here are the tenancy packages I'm aware of, of course, there may be more:

* stancl/tenancy * gecche/laravel-multidomain * romegadigital/multitenancy * tenancy/tenancy * hyn/multi-tenant * spatie/laravel-multitenancy

From first glance, each one of these packages look very similar. They all say they do the same thing (mostly), and to someone who hasn't dived too deep into tenancy, it would be difficult to discern the differences.

I've looked over this list for the past year, and honestly, I've had a hard time "committing" to one. But I've learned that tenancy/tenancy officially launched 1.0 a few weeks ago, and Spatie released laravel-multi-tenancy shortly after. Here are two great packages worth checking out, both officially released days from each other. Can you feel the pressure? The tenancy battle rages on!

This is all great, right? I'm truly excited to see the future of "tenancy" (that's me being tenancy-brand-agnostic) for Laravel.

The one thing that is truly missing is a decent comparison chart for people like you and me to understand the differences, nuances, estimated level complexity for integration into existing systems, etc. If anyone knows of comparisons for the packages above, please share.

I'm mostly interested in tenancy/tenancy and spatie/laravel-multitenancy as they are both the newest and appear to be pretty similar.

What do you guys think about tenancy in Laravel?

----

**Update:**

Thanks for all of the responses! Here's where I landed: - I removed the Tenant changes added from the YT video by Mohamed Said - I tend to agree w/ the stancl/tenancy approach, it looks like it can be mostly side-loaded. I spent more time reading the documentation about the config.php file and some other tweaks to my database.php. The actual implementation was pretty fast. My application relies on a tenant model having a tenant key, so there's still a little more work I need to do, but out of the box it delivers a consistent user experience; no problems with sessions, cache, etc. I was ready to devote 4-8 hours to get tenancy/tenancy migrated into my application, so with all things considered, I'd call this a win!

----

*TLDR: There are so many packages that look the same. There's no comparison chart. And tenancy/tenancy & spatie/laravel-multitenancy are dropping releases for "unopinionated" tenancy frameworks at the same time.*

— 0