laravel-multitenancy-development

Installation
SKILL.md

Laravel Multitenancy Development

When to use this skill

Use this skill when working with multi-tenant Laravel applications using spatie/laravel-multitenancy: determining the current tenant per request, isolating databases or caches per tenant, making queued jobs and artisan commands tenant-aware, or designing landlord/tenant migration strategies.

Core Concepts

  • Intentionally minimal: the package resolves a current tenant and runs tasks on switch — it does not add global query scopes or model isolation by itself.
  • Current tenant is bound in the IoC container under the key currentTenant and written to Laravel Context under the key tenantId.
  • A TenantFinder resolves the tenant from the current HTTP request (e.g. by domain).
  • SwitchTenantTask classes mutate the environment when a tenant becomes current (switch DB, prefix cache, etc.) and restore it when forgotten.
  • Models on the landlord DB use UsesLandlordConnection; models on the tenant DB use UsesTenantConnection.

Setup

Installs
6
GitHub Stars
1.4K
First Seen
May 23, 2026
laravel-multitenancy-development — spatie/laravel-multitenancy