// the find
archtechx/tenancy
Automatic multi-tenancy for Laravel. No code changes needed.
A Laravel package that bolts multi-tenancy onto an existing app by swapping database connections, cache prefixes, filesystem roots, and queue contexts at the bootstrapper level — before your application code runs. Targets SaaS builders who want per-tenant database isolation (separate DB, Postgres schema, or row-level security) without rewriting their models. The 'no code changes needed' pitch is mostly true for greenfield apps; brownfield installs require more care.
The bootstrapper architecture is the real value here: it hooks into Laravel's service container resolution so that Cache, Storage, DB, Mail, and Queue all transparently switch context for each tenant without traits or facade swaps in application code. Postgres RLS support is genuinely well done — it generates actual PG policies and manages a per-tenant DB user, which is the right way to enforce row-level isolation rather than just WHERE clauses in scopes. Pending tenant support (pre-warming databases before a tenant actually signs up) is a practical SaaS feature that most competitors skip. The test suite is extensive and covers the bootstrappers individually, which is the right approach since that's where subtle state-leakage bugs hide.
Queue tenancy is the weak spot — jobs that dispatch other jobs, or third-party packages that queue internally, can easily drop tenant context, and the distinction between QueueTenancyBootstrapper and PersistentQueueTenancyBootstrapper is a footgun waiting for someone who doesn't read far enough into the docs. The separate-database strategy hits real operational walls past a few hundred tenants: connection pool exhaustion, backup complexity, and schema drift between tenants all become your problem. Any code that bypasses the container (raw PDO, direct config reads, packages that cache DB connections at boot) silently breaks isolation with no error — the automatic context switching only works if everything goes through the service container. The README still shows a Laravel 10.x badge despite the package being on v4.