# archtechx/tenancy

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/archtechx-tenancy).**

4,274 stars · 485 forks · PHP · mit

## Links

- GitHub: https://github.com/archtechx/tenancy
- Homepage: https://tenancyforlaravel.com
- awesome-repositories: https://awesome-repositories.com/repository/archtechx-tenancy.md

## Topics

`laravel` `multi-tenancy` `multitenancy` `saas` `software-as-a-service` `tenancy` `tenant`

## Description

Tenancy is a PHP package that provides multi-tenant architecture for Laravel applications, automatically isolating data and operations per tenant. It identifies the active tenant from the incoming request's hostname, including support for second-level domains, and scopes all database queries, cache, and storage to that tenant without requiring manual filtering or model trait modifications.

The package automatically detects the current tenant from the request context and sets it for the session, ensuring each tenant sees only its own data. It also supports running background jobs that are scoped to a single tenant, keeping job data and side effects isolated from other tenants.

## Tags

### Data & Databases

- [Hostname-Based Tenant Identifiers](https://awesome-repositories.com/f/data-databases/multi-tenant-data-management/multi-tenant-authentication-configurations/hostname-based-tenant-identifiers.md) — Identifies the active tenant from the request hostname, including second-level domain support. ([source](https://cdn.jsdelivr.net/gh/archtechx/tenancy@master/README.md))
- [Request-Based Tenant Detectors](https://awesome-repositories.com/f/data-databases/multi-tenant-data-management/tenant-request-routing/request-based-tenant-detectors.md) — Detects the current tenant from the request context and sets it for the session. ([source](https://v4.tenancyforlaravel.com))
- [Automatic Query Scoping](https://awesome-repositories.com/f/data-databases/multi-tenant-data-stores/per-tenant-block-indexes/automatic-query-scoping.md) — Automatically isolates database queries and storage per tenant without manual filtering. ([source](https://v4.tenancyforlaravel.com))
- [Automatic Request Scoping](https://awesome-repositories.com/f/data-databases/tenant-model-scoping/automatic-request-scoping.md) — Automatically scopes all database queries, cache, and storage to the current tenant per request. ([source](https://cdn.jsdelivr.net/gh/archtechx/tenancy@master/README.md))

### Part of an Awesome List

- [Tenant-Scoped Job Executions](https://awesome-repositories.com/f/awesome-lists/devtools/job-scheduling/tenant-scoped-job-executions.md) — Executes background tasks scoped to a single tenant, keeping job data and side effects isolated. ([source](https://v4.tenancyforlaravel.com))
