spatie/laravel-multitenancy
Unopinionated multitenancy for Laravel. Detect the current tenant per request and run configurable tasks when switching tenants. Supports single or multiple databases, tenant-aware queued jobs, per-tenant Artisan commands, and easy model connection handling.
tenant1.app.com) or API-based tenant resolution (e.g., X-Tenant-ID header).IsTenant contract; alternatives like tenancy/tenancy offer tighter model integration)./tenant1/dashboard); consider gecche/laravel-multidomain.tenancy/tenancy).tenancy/tenancy provides more scaffolding for common SaaS patterns)."This package lets us launch a multi-tenant SaaS platform without building multitenancy from scratch—saving 3–6 months of dev time. It handles the heavy lifting:
acme.app.com → Acme’s data only).tenancy/tenancy offer more scaffolding but lock us into their roadmap. This gives us flexibility to customize later."ROI:
"This is a minimalist, contract-based multitenancy solution for Laravel. Here’s why it’s a great fit:
TenantFinder classes.TenantAware or configure globally.tenant:artisan.IsTenant contract).Trade-offs vs. Alternatives:
| Feature | spatie/laravel-multitenancy |
tenancy/tenancy |
|---|---|---|
| Tenant-specific models | ❌ (Generic IsTenant) |
✅ (Built-in) |
| Opinionated scaffolding | ❌ | ✅ (Migrations, seeds) |
| Customization | ✅ (Contracts, tasks) | ⚠️ (Limited) |
| Learning curve | Low | Medium |
Recommendation: Use this for core isolation and pair with:
laravel-breeze/inertiajs for tenant-specific UIs.spatie/laravel-permission for role-based access control (RBAC) per tenant.Next Steps:
DomainTenantFinder).How can I help you explore Laravel packages today?