mirror of
https://github.com/stancl/tenancy-docs.git
synced 2025-12-12 18:24:03 +00:00
114 lines
No EOL
5.5 KiB
Markdown
114 lines
No EOL
5.5 KiB
Markdown
---
|
|
title: Compared to other packages
|
|
extends: _layouts.documentation
|
|
section: content
|
|
---
|
|
|
|
# Compared to other packages
|
|
|
|
## hyn/multi-tenancy
|
|
|
|
This package intends to provide you with the necessary tooling for adding multi-tenancy **manually** to your application. It will give you model traits, classes for creating tenant databases, and some additional tooling.
|
|
|
|
It would have been a good option for when you want to implement multi-tenancy manually, but:
|
|
|
|
- It isn't being actively developed — no features have been added in the past ~year
|
|
- It makes testing a nightmare.
|
|
|
|
Over the last few months, I've received this feedback:
|
|
|
|
> But, I still can't run any tests in Hyn, and had some queuing problems I'm still nervous about.
|
|
|
|
> At the moment, our app is using latest Laravel and latest hyn/tenancy. The only thing I don't like about it is that tests are extremely fragile to the point where I don't dare mess with anything for risk of breaking everything
|
|
|
|
> By the way, this package is awesome! It's so much better than the hyn alternative which is a bit of a mess in my opinion... It is a pity that I did not come across it in the first place.
|
|
|
|
I'm not sharing this to intentionally make hyn/multi-tenancy bad, but **be very careful if you decide to go with that package**.
|
|
|
|
- It will very likely be sunset — or, in other words, killed — soon, since tenancy/tenancy is being released.
|
|
|
|
## tenancy/tenancy
|
|
|
|
This package intends to provide you with a framework for building your own multi-tenancy implementation. The documentation is quite lacking, so I couldn't get a too detailed idea of what it does, but from my understanding, it gives you things like events which you can use to build your own multi-tenancy logic.
|
|
|
|
If you want the absolute highest flexibility and would otherwise build your own implementation, looking into this package might be useful.
|
|
|
|
However, if you're looking for a package that will help you make a multi-tenant project quickly, this is probably not the right choice.
|
|
|
|
## spatie/laravel-multitenancy
|
|
|
|
It's hard to find good things to say about this package. It's basically a simplified copy of v2 of stancl/tenancy.
|
|
|
|
stancl/tenancy was the first package to use the automatic approach. The Spatie package is a copy of that, though in Freek's words, he hasn't looked into other packages prior to developing his.
|
|
|
|
[https://twitter.com/freekmurze/status/1257765177174482944](https://twitter.com/freekmurze/status/1257765177174482944)
|
|
|
|
(That, in my opinion, is a red flag, since you'd want to do research before just blindly coding something and marketing it.)
|
|
|
|
The package is basically Mohamed Said's video series on multi-tenancy glued into a package.
|
|
|
|
They also don't seem to have an interest in having their package help the largest amount of people:
|
|
|
|
[https://twitter.com/freekmurze/status/1260187383191961601](https://twitter.com/freekmurze/status/1260187383191961601)
|
|
|
|
The only benefit I see in this package compared to v2 of stancl/tenancy is that it uses Eloquent out of the box, which makes things like Cashier integration easier. But, that's irrelevant since we're in v3 already and v3 uses Eloquent.
|
|
|
|
So, I suggest you consider this package only if you value simplicity for some reason, and aren't building anything with any amount of complexity and need for "business features".
|
|
|
|
## stancl/tenancy
|
|
|
|
In my — biased, of course, but likely true as well — opinion, this package is the absolute best choice for the vast majority of applications.
|
|
|
|
The only packages I'd realistically consider are mine (of course) and tenancy/tenancy if you need something **very** custom, though I don't see the reason for that in 99% of applications.
|
|
|
|
This package attempts to be about as flexible as tenancy/tenancy, but also provide you with the absolute largest amount of out-of-the-box features and other tooling. It continues its path as the first package to have been using the automatic approach with adding many more features — most of which are "enterprise" features, in v3.
|
|
|
|
To give you an incomplete-but-good-enough list of features, this package supports:
|
|
|
|
- Multi-database tenancy
|
|
- creating databases
|
|
- MySQL
|
|
- PostgreSQL
|
|
- PostgreSQL (schema mode)
|
|
- SQLite
|
|
- creating database users
|
|
- automatically switching the database
|
|
- CLI commands, with more features than e.g. spatie/laravel-multitenancy
|
|
- migrate
|
|
- migrate:fresh
|
|
- seed
|
|
- Single-database tenancy
|
|
- model traits with global scopes
|
|
- Rich event system
|
|
- **Very high testability**
|
|
- Automatic tenancy
|
|
- tenancy bootstrappers to switch:
|
|
- database connections
|
|
- redis connections
|
|
- cache tags
|
|
- filesystem roots
|
|
- queue context
|
|
- Manual tenancy
|
|
- model traits
|
|
- Out of the box tenant identification
|
|
- domain identification
|
|
- subdomain identification
|
|
- path identification
|
|
- request data identification
|
|
- middleware classes for the methods above
|
|
- CLI argument identification
|
|
- manual identification (e.g. in tinker)
|
|
- Integration with many packages
|
|
- spatie/laravel-medialibrary
|
|
- spatie/laravel-activitylog
|
|
- Livewire
|
|
- Laravel Nova
|
|
- for managing tenants
|
|
- for **using inside the tenant application**
|
|
- Laravel Horizon
|
|
- Laravel Telescope
|
|
- Laravel Passport
|
|
- **Syncing users (or any other database resources) between multiple tenant databases**
|
|
- Dependency injection of the current tenant
|
|
- Tenant **user impersonation**
|
|
- **Cached tenant lookup**, universal for all tenant resolvers |