laraflock/multi-tenant
A Laravel package for building multi-tenant applications with tenant-aware database connections, migrations, and model scoping. It helps isolate tenant data and switch between tenants easily, supporting both single-database and multi-database setups.
tenancy/multi-tenant is the actively maintained successor to stancl/tenancy, and it is the de facto standard multitenancy package for Laravel. The 5.9.1 patch re-adds Laravel 9 support to the 5.x line, which is a compatibility correction rather than a feature release: 5.9.0 evidently tightened the supported framework range, and 5.9.1 walks that back so Laravel 9 applications can still consume the current 5.x branch.
Architecture fit. The package is opinionated about how tenancy is wired into the framework. It owns tenant resolution (domain, subdomain, path, or custom resolvers), bootstrapping (switching database connections, cache stores, filesystem roots, queue configuration, Redis prefixes), and a lifecycle of events around tenant initialization and teardown. This is a good fit if your application is already conventionally Laravel-shaped: Eloquent models, service container, facades, queued jobs, and the standard HTTP kernel. It is a poor fit if the application has heavy global state, long-lived workers that predate the package's bootstrapper model, or significant non-Laravel code paths that touch the database directly. The central TPM decision is single-database (row-scoped via a tenant column) versus multi-database (one schema/database per tenant). The package supports both, but they carry very different operational profiles — see Operational Impact.
Integration feasibility. Integration effort is moderate and well-documented. Expect to define a Tenant model, configure a resolver, register middleware, and audit every place the application assumes a single connection. The package provides tenant-aware jobs, cache, filesystem, and Redis out of the box, which removes the most painful custom work. The genuinely hard part is not installing the package; it is auditing existing code for implicit global assumptions — raw queries against the default connection, hard-coded storage paths, singleton services that capture tenant data at container-build time, and any code that runs before the tenant is resolved.
Technical risk. Several areas warrant explicit scrutiny before committing:
Key questions for the engineering team.
Stack fit. The package targets Laravel 9, 10, and 11 on the 5.x line as of 5.9.1. It assumes PHP 8.x, Composer, and a standard Laravel service-provider bootstrapping model. If the surrounding platform is Laravel-native, integration is largely additive: a config file, a Tenant model, middleware, and a set of bootstrappers. If the platform is a hybrid (e.g., Laravel alongside a legacy PHP service, or a Laravel API behind a non-Laravel gateway), the tenant resolution boundary must be agreed at the edge and passed through unambiguously, otherwise the package will resolve tenancy from the wrong signal.
Migration path. For an existing single-tenant application, the realistic path is staged:
The 5.9.1 release specifically de-risks step 1 for Laravel 9 shops: it means you do not have to bundle a framework upgrade into the tenancy integration. Keeping those two changes separate is worth insisting on — a combined framework-plus-tenancy upgrade is materially harder to debug and to roll back.
Compatibility. Treat the Laravel version constraint as a first-class dependency in planning. Because 5.9.0 briefly narrowed support and 5.9.1 restored it, pin the package to a specific minor and require an explicit review before any bump. Record the supported matrix (Laravel 9/10/11) in the platform runbook and re-verify it at each framework upgrade. Also verify the status of secondary packages that interact with connections, queues, and storage — those are where incompatibilities actually surface, not in the tenancy package itself.
Sequencing. Land tenancy in a horizontal slice (resolution, bootstrapping, middleware) before touching feature code, so the isolation boundary is testable in isolation. Then convert features by domain area, starting with read paths and ending with writes and background processing. Do not attempt to convert queue and scheduler behavior in the same change set as the HTTP path; they fail differently and need separate verification.
Maintenance. The package is actively maintained with a steady release cadence and responsive maintainers, which is the main reason to prefer it over the archived stancl/tenancy. The maintenance burden that lands on your team is not the package itself but the ongoing audit discipline: every new feature, every new background job, and every third-party package added must be checked against the tenancy boundary. Budget for this as a permanent tax on feature work, not a one-time integration cost. The 5.9.1 patch also illustrates that framework-version support can move in patch releases, so the dependency must be watched, not just installed.
Support. Community support via GitHub issues and documentation is good but not contractual. For a revenue-bearing multi-tenant platform, designate an internal owner for tenancy — someone accountable for the version matrix, the isolation test suite, and the onboarding runbook. Without a named owner, isolation regressions accumulate silently until a customer notices.
Scaling. Scaling characteristics differ sharply by model:
In both models, the failure mode to design against is connection-pool exhaustion and migration storms during deploys that touch many tenants.
Failure modes. The ones worth writing runbooks for:
Ramp-up. Assume meaningful ramp-up for the team beyond reading the docs. The concepts are not difficult, but the failure modes are subtle and only surface in background processing and edge routing. Plan for: a short internal enablement session on the bootstrapper lifecycle; a written tenancy conventions doc covering connection usage, cache keys, storage paths, and job patterns; and an isolation test harness in CI before the first external tenant is onboarded. Realistic estimate: one to two weeks for a mid-level Laravel engineer to be productive, and considerably longer before they reliably avoid the leakage failure modes without review. The highest-leverage investment is the conventions doc plus the CI isolation suite — those convert per-engineer vigilance into a repeatable check.
Recommendation. Adopt 5.9.1 as the baseline for new multitenancy work, specifically because it preserves Laravel 9 support and lets the tenancy integration proceed independently of a framework upgrade. Pin to 5.9.x, designate an internal owner, and make the tenancy model decision (single-database vs. database-per-tenant) before any code is written — that choice determines the operational shape and is expensive to reverse.
How can I help you explore Laravel packages today?