PHPackages                             artflow-studio/tenancy - 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. [Database &amp; ORM](/categories/database)
4. /
5. artflow-studio/tenancy

ActiveLibrary[Database &amp; ORM](/categories/database)

artflow-studio/tenancy
======================

Enterprise-grade standalone Laravel multi-tenancy package for Laravel 12 &amp; 13 — domain-based isolation, Livewire 4 integration, and zero stancl/tenancy dependency.

0.8.4(3mo ago)088MITPHPPHP &gt;=8.2

Since Nov 7Pushed 2mo agoCompare

[ Source](https://github.com/rahee554/AF-MultiTenancy)[ Packagist](https://packagist.org/packages/artflow-studio/tenancy)[ Docs](https://github.com/artflow-studio/tenancy)[ RSS](/packages/artflow-studio-tenancy/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (12)Versions (6)Used By (0)

artflow-studio/tenancy
======================

[](#artflow-studiotenancy)

**Standalone Laravel multi-tenancy package for the Artflow CRM platform.**

- Domain-based database isolation — each subdomain gets its own MySQL database
- No `stancl/tenancy` dependency — fully self-contained since v0.8.4.0
- Redis optional — auto-fallback to `database` store keeps TTFB below 200ms
- Built for Laravel 12, PHP 8.2+, Livewire 3

---

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

[](#requirements)

DependencyVersionPHP8.2+Laravel12.xMySQL / MariaDB8.0+ / 10.4+predis/predisAny (optional)---

Quick Start
-----------

[](#quick-start)

```
# 1. Install
composer require artflow-studio/tenancy

# 2. Configure and migrate
php artisan af-tenancy:install --no-interaction

# 3. Create a tenant
php artisan tenant:create

# 4. Verify
php artisan tenant:health
```

Add to `.env`:

```
APP_DOMAIN=yourdomain.com
AF_TENANCY_CACHE_STORE=database
```

---

How It Works
------------

[](#how-it-works)

Every HTTP request to `{tenant}.yourdomain.com` passes through `InitializeTenancyByDomain` (auto-prepended to the `web` group). The middleware resolves the hostname against the central `domains` table — result cached for 1 hour — and switches Laravel's DB connection to the tenant's database. The connection is restored when the request ends.

```
Request → InitializeTenancyByDomain
  ↓
  DomainResolver.resolve($host)  ← cache hit (~1ms) or DB JOIN (~3ms)
  ↓
  Tenancy::initialize($tenant)
  ↓
  DatabaseBootstrapper → switch DB
  CacheBootstrapper    → prefix cache keys
  SessionBootstrapper  → scope sessions
  ↓
  [Request handled in tenant context]
  ↓
  Tenancy::end() → restore central DB

```

---

Tenant Routes
-------------

[](#tenant-routes)

```
// Tenant-scoped routes
Route::middleware(['auth', 'tenant.web'])->prefix('business')->group(function () {
    Route::get('/dashboard', BusinessDashboard::class);
});

// Central-only admin routes
Route::middleware(['central.web', 'auth'])->prefix('admin')->group(function () {
    Route::get('/tenants', TenantsIndex::class);
});

// Both central and tenant
Route::middleware(['universal.web'])->group(function () {
    Route::get('/login', LoginPage::class)->name('login');
});
```

---

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

[](#configuration)

`config/artflow-tenancy.php` key sections:

```
'central_domains' => [env('APP_DOMAIN', 'localhost')],

'bootstrappers' => [
    \ArtflowStudio\Tenancy\Bootstrappers\DatabaseBootstrapper::class,  // required, first
    // \ArtflowStudio\Tenancy\Bootstrappers\CacheBootstrapper::class,
    // \ArtflowStudio\Tenancy\Bootstrappers\SessionBootstrapper::class,
    // \ArtflowStudio\Tenancy\Bootstrappers\FilesystemBootstrapper::class,
],

'cache' => [
    'resolver_store'          => env('AF_TENANCY_CACHE_STORE', 'database'),
    'resolver_fallback_store' => env('AF_TENANCY_CACHE_FALLBACK_STORE', 'database'),
    'resolver_ttl'            => env('AF_TENANCY_CACHE_TTL', 3600),
],
```

---

Helpers
-------

[](#helpers)

```
tenancy()               // Tenancy singleton
tenant()                // Active Tenant model or null
get_current_domain()    // Current hostname
tenant_pwa_asset($path) // URL to tenant PWA asset
```

---

Artisan Commands
----------------

[](#artisan-commands)

```
# Tenant lifecycle
php artisan tenant:create
php artisan tenant:list
php artisan tenant:delete {uuid}
php artisan tenant:health

# Database
php artisan tenant:db migrate
php artisan tenant:db migrate --tenant={uuid}
php artisan tenant:connection-test

# SEO & PWA
php artisan tenant:seo:enable --tenant={uuid}
php artisan tenant:pwa:enable --tenant={uuid}

# Diagnostics
php artisan tenancy:performance
php artisan tenant:tinker {uuid}
```

---

Testing
-------

[](#testing)

```
$tenant = Tenant::factory()->create();

$tenant->run(function () {
    User::create(['name' => 'Alice', 'email' => 'alice@example.com', 'password' => bcrypt('x')]);
    expect(User::count())->toBe(1);
});
```

```
php artisan test tests/Feature/Tenancy/
```

---

Documentation
-------------

[](#documentation)

Open `docs/index.html` in your browser for the full interactive documentation.

---

Changelog
---------

[](#changelog)

See [CHANGELOG.md](CHANGELOG.md).

---

License
-------

[](#license)

Proprietary — Artflow Studio. Internal use only.

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance82

Actively maintained with recent releases

Popularity9

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Every ~34 days

Total

5

Last Release

102d ago

PHP version history (2 changes)0.8.0PHP &gt;=8.0

0.8.4PHP &gt;=8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/76494683?v=4)[Raheel Ahmad](/maintainers/rahee554)[@rahee554](https://github.com/rahee554)

---

Top Contributors

[![rahee554](https://avatars.githubusercontent.com/u/76494683?v=4)](https://github.com/rahee554 "rahee554 (7 commits)")

---

Tags

laraveldatabaseisolationlivewireenterprisesaasmulti-tenancytenancy

###  Code Quality

TestsPest

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/artflow-studio-tenancy/health.svg)

```
[![Health](https://phpackages.com/badges/artflow-studio-tenancy/health.svg)](https://phpackages.com/packages/artflow-studio-tenancy)
```

###  Alternatives

[unopim/unopim

UnoPim Laravel PIM

10.5k2.4k](/packages/unopim-unopim)[bagisto/bagisto

Bagisto Laravel E-Commerce

27.6k172.1k9](/packages/bagisto-bagisto)[anourvalar/eloquent-serialize

Laravel Query Builder (Eloquent) serialization

11223.5M33](/packages/anourvalar-eloquent-serialize)[waad/laravel-model-metadata

A robust Laravel package for handling metadata with JSON casting, custom relation names, and advanced querying capabilities.

854.6k](/packages/waad-laravel-model-metadata)[tomatophp/filament-tenancy

Tenancy multi-database integration for FilamentPHP

624.4k](/packages/tomatophp-filament-tenancy)[ramadan/easy-model

A Laravel package for enjoyably managing database queries.

111.6k](/packages/ramadan-easy-model)

PHPackages © 2026

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