Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Tenancy Laravel Package

stancl/tenancy

Automatic multi-tenancy for Laravel apps with minimal code changes. Provides tenant identification (e.g., by hostname/subdomains), isolated tenant bootstrapping, and tenancy-aware database/config switching without swapping core Laravel classes or adding model traits.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Multi-Tenant SaaS Architecture: Enables seamless isolation of data, configurations, and assets for each tenant without modifying core application logic. Ideal for scaling horizontally while maintaining strict data separation.
  • Accelerated Time-to-Market: Reduces development effort for tenant-specific features (e.g., subdomains, custom branding) by abstracting tenancy logic into a plug-and-play package.
  • Build vs. Buy Decision: Justifies buying this package over custom development for teams lacking multi-tenancy expertise, given its zero-code-overhead approach and Laravel-native integration.
  • Roadmap Priorities:
    • Phase 1: Launch a single-tenant MVP, then adopt tenancy for scalability.
    • Phase 2: Implement tenant-specific pricing, features, or compliance (e.g., GDPR) without refactoring.
    • Phase 3: Expand to multi-region tenancy (e.g., EU/US data residency) using the package’s extensible resolver system.
  • Use Cases:
    • B2B Platforms: Isolate client data (e.g., CRM, project management tools).
    • Marketplaces: Separate vendor data (e.g., Shopify, Airbnb).
    • Regulated Industries: HIPAA/GDPR compliance via tenant-scoped data access.
    • Internal Tools: Departmental portals (e.g., HR, finance) with shared infrastructure.

When to Consider This Package

Adopt if:

  • Your Laravel app is monolithic but needs to scale into a multi-tenant SaaS.
  • Tenants require subdomain isolation (e.g., client1.yourapp.com) with minimal DNS/config changes.
  • You prioritize developer velocity over custom tenancy logic (e.g., no model traits, no Laravel class replacements).
  • Tenants share core logic but need isolated data (e.g., shared auth, but separate databases).
  • Your stack includes Laravel 10–13 and PHP 8+ (active support for modern versions).
  • You need built-in tenant identification via hostname, path, or custom resolvers (e.g., API keys, cookies).

Look elsewhere if:

  • You require shared-database tenancy (this package uses separate schemas/databases).
  • Tenants need dynamic schema creation at runtime (e.g., per-request schemas)—consider Laravel’s Schema::create events or spatie/laravel-schema-manager.
  • Your app uses non-Laravel services (e.g., Node.js microservices) that can’t integrate with Laravel’s middleware.
  • You need tenant-specific PHP extensions (e.g., custom PHP.ini per tenant)—this package isolates databases/filesystems, not runtime environments.
  • Your compliance needs audit logs for tenant switching—this package lacks built-in logging; pair with Laravel Audit or custom middleware.

How to Pitch It (Stakeholders)

For Executives: *"stancl/tenancy lets us launch a multi-tenant SaaS without rewriting our Laravel app. It automatically isolates each customer’s data, files, and configurations by subdomain (e.g., acme.yourapp.com), so we can:

  • Scale horizontally by adding tenants without infrastructure changes.
  • Reduce dev costs by avoiding custom tenancy logic (saves 3–6 months of work).
  • Future-proof for compliance (GDPR/HIPAA) via tenant-scoped databases.
  • Monetize faster by enabling tenant-specific features (e.g., custom branding) with zero code changes. Used by 4,000+ repos, it’s battle-tested and MIT-licensed—no vendor lock-in. Let’s pilot it with our top 3 clients to validate before full rollout."

For Engineering: *"This package eliminates tenancy boilerplate in Laravel by:

  • Transparent tenant switching: No model traits, no replacing Cache, Storage, etc.—just install and configure.
  • Resolver flexibility: Identify tenants via subdomains, paths, or custom logic (e.g., API keys).
  • Queue/Job support: Tenant-aware job processing with zero flakiness (fixed in v3.5+).
  • Asset isolation: Tenant-scoped Vite assets, filesystems, and caches out of the box.
  • Laravel-native: Works with 10–13, supports PostgreSQL/MySQL/MariaDB, and has active maintenance (3.10.0 released March 2026). Tradeoff: Separate databases/schemas (not shared tables). If that’s acceptable, this is a no-brainer for SaaS builds. Let’s prototype with their starter kit and validate performance with our expected tenant load."*

For Security/Compliance: *"Key advantages for governance:

  • Data isolation: Each tenant gets a dedicated database/schema, preventing cross-tenant data leaks.
  • Audit-ready: Pair with Laravel’s logging to track tenant access (though add custom middleware for switching logs).
  • GDPR/HIPAA alignment: Tenant-scoped data deletion is straightforward (e.g., Tenant::findOrFail($id)->delete() drops the entire schema). Limitation: No built-in tenant activity logging—we’d need to layer Laravel Audit or custom middleware. Worth the tradeoff for the speed gains."*
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport