PHPackages                             ronu/multitenancy-laravel - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. ronu/multitenancy-laravel

ActiveLibrary[Framework](/categories/framework)

ronu/multitenancy-laravel
=========================

AppContext-integrated multi-tenancy for Laravel.

00PHP

Since Feb 10Pushed 3mo agoCompare

[ Source](https://github.com/charlietyn/multitenancy-laravel)[ Packagist](https://packagist.org/packages/ronu/multitenancy-laravel)[ RSS](/packages/ronu-multitenancy-laravel/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel Multi-Tenancy (AppContext-based)
========================================

[](#laravel-multi-tenancy-appcontext-based)

A lightweight multi-tenancy layer designed to integrate with `ronu/laravel-app-context`. It provides global tenant scoping, tenant-aware model behavior, and middleware validation, with minimal overhead when disabled.

Key Features
------------

[](#key-features)

- Global tenant scope for Eloquent models
- Tenant-aware model creation and updates
- Per-channel enable/disable based on AppContext channels
- Auto-detection of tenancy based on channel configuration
- Strict, soft, or disabled enforcement modes
- Optional bypass mode for superusers
- Artisan command to inspect status

Requirements
------------

[](#requirements)

- PHP 8.1+
- Laravel 9, 10, or 11
- `ronu/laravel-app-context`

Installation
------------

[](#installation)

1. Require the AppContext package.
2. Require this package (or include it as a local package).
3. Register the service provider if you are not using auto-discovery.
4. Publish the config file.

```
php artisan vendor:publish --tag=tenancy-config
```

Configuration
-------------

[](#configuration)

Main config file: `config/tenancy.php`

Environment variables (from `.env.example`):

- `TENANCY_ENABLED` true | false | empty (auto-detect)
- `TENANCY_COLUMN` default tenant column, e.g. `tenant_id`
- `TENANCY_ENFORCEMENT_MODE` strict | soft | disabled
- `TENANCY_ADMIN_ENABLED` override per channel
- `TENANCY_MOBILE_ENABLED` override per channel
- `TENANCY_SITE_ENABLED` override per channel
- `TENANCY_PARTNER_ENABLED` override per channel
- `TENANCY_LOG_BYPASSES` true | false
- `TENANCY_LOG_CONTEXT_CHANGES` true | false
- `TENANCY_ALERT_VIOLATIONS` true | false

### AppContext Integration

[](#appcontext-integration)

This package reads the current channel and tenant from AppContext:

- `app-context.channels.{channel}.tenant_mode` determines default behavior.
- `TenantOwnershipValidator` hydrates the tenant context from AppContext.
- `TenantScope` applies tenant filtering automatically.

Usage
-----

[](#usage)

### Apply tenant behavior to a model

[](#apply-tenant-behavior-to-a-model)

```
use Ronu\MultitenancyLaravel\Traits\TenantAware;

class Order extends Model
{
    use TenantAware;
}
```

### Tenant scope helpers

[](#tenant-scope-helpers)

```
Order::query()->withoutTenantScope()->get();
Order::query()->forTenant($tenantId)->get();
```

### Middleware

[](#middleware)

Register `TenantOwnershipValidator` after `ctx.auth` / `ctx.bind` so it can read AppContext.

### Status command

[](#status-command)

```
php artisan tenancy:status
php artisan tenancy:status --detailed
```

Security Notes
--------------

[](#security-notes)

- Cross-tenant operations require a superuser resolver.
- Tenant ID modification on updates is blocked by `TenantAware`.

Known Issues (Resolved)
-----------------------

[](#known-issues-resolved)

- Namespace mismatches were standardized to `Ronu\\MultitenancyLaravel`.

License
-------

[](#license)

MIT

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance55

Moderate activity, may be stable

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity12

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/0f59437a00cb4187df5eeb376f1c72053def2a2b16227a1e70d0c48ab2c99a4e?d=identicon)[charlietyn](/maintainers/charlietyn)

---

Top Contributors

[![charlietyn](https://avatars.githubusercontent.com/u/10063918?v=4)](https://github.com/charlietyn "charlietyn (2 commits)")

### Embed Badge

![Health badge](/badges/ronu-multitenancy-laravel/health.svg)

```
[![Health](https://phpackages.com/badges/ronu-multitenancy-laravel/health.svg)](https://phpackages.com/packages/ronu-multitenancy-laravel)
```

###  Alternatives

[laravel/passport

Laravel Passport provides OAuth2 server support to Laravel.

3.4k85.0M532](/packages/laravel-passport)[nolimits4web/swiper

Most modern mobile touch slider and framework with hardware accelerated transitions

41.8k177.2k1](/packages/nolimits4web-swiper)[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k36.7M259](/packages/laravel-dusk)[laravel/prompts

Add beautiful and user-friendly forms to your command-line applications.

712181.8M596](/packages/laravel-prompts)[cakephp/chronos

A simple API extension for DateTime.

1.4k47.7M121](/packages/cakephp-chronos)[laravel/pail

Easily delve into your Laravel application's log files directly from the command line.

91545.3M590](/packages/laravel-pail)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
