spatie/laravel-multitenancy
Unopinionated multitenancy for Laravel: detect the current tenant per request and define what happens when switching tenants. Supports single or multiple databases, tenant-aware queues/jobs, per-tenant artisan commands, and easy model connection switching.
IsTenant contract and extensibility remain intact, enabling flexible tenant model implementations.multitenancy.php) remains unchanged.multitenancy.php as before.DomainTenantFinder).ResolveCurrentTenant middleware.queues_are_tenant_aware_by_default).| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Tenant resolution fails | 500 errors for affected requests | Fallback tenant or graceful degradation |
| Database connection drops | Tenant-aware queries fail | Retry logic, circuit breakers |
| Job retry with invalid payload | Job fails with CurrentTenantCouldNotBeDeterminedInTenantAwareJob |
New: Validate payload serialization; implement retry with tenant lookup from context |
| Tenant-aware job processes deleted tenant | Job fails with tenant resolution error | New: Enhanced payload context may reduce occurrences; monitor for failures |
| Shared schema data leakage | Tenant data visible to others | Strict tenant_id checks in queries |
| Queue worker crashes | Tenant-aware jobs stall | Supervisor restarts, dead-letter queues |
How can I help you explore Laravel packages today?