PHPackages                             protosofia/ben10ant - 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. protosofia/ben10ant

ActiveLibrary[Framework](/categories/framework)

protosofia/ben10ant
===================

A really usefull Multi-Tenancy package for Laravel, it's serious, at least i'm trying to

v1.0.6(7y ago)142211[1 issues](https://github.com/protosofia/ben10ant/issues)MITPHP

Since Apr 24Pushed 7y ago3 watchersCompare

[ Source](https://github.com/protosofia/ben10ant)[ Packagist](https://packagist.org/packages/protosofia/ben10ant)[ RSS](/packages/protosofia-ben10ant/feed)WikiDiscussions master Synced today

READMEChangelog (6)Dependencies (2)Versions (8)Used By (0)

ben10ant
========

[](#ben10ant)

A really usefull Multi-Tenancy package for Laravel, it's serious, at least i'm trying to...

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

[](#installation)

```
composer require protosofia/ben10ant

```

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

[](#configuration)

### Console Commands Configuration

[](#console-commands-configuration)

Add to app/Console/Kernel.php:

```
...
protected $commands = [
    ...
    \Protosofia\Ben10ant\Commands\TenantCreate::class,
    \Protosofia\Ben10ant\Commands\TenantMigrate::class,
    \Protosofia\Ben10ant\Commands\TenantMigrateRefresh::class,
    \Protosofia\Ben10ant\Commands\TenantMigrateRollback::class,
    \Protosofia\Ben10ant\Commands\TenantSeed::class,
    ...
];
...

```

### Middleware Configuration

[](#middleware-configuration)

Add to app/Http/Kernel.php:

```
...
protected $middleware = [
    ...
    \Protosofia\Ben10ant\Middlewares\CheckTenantByKey::class,
    ...
];
...

```

### Provider Configuration

[](#provider-configuration)

Add to config/app.php:

```
...
'providers' => [
    ...
    \Protosofia\Ben10ant\Providers\TenantServiceProvider::class,
    ...
],
...

```

### Facade

[](#facade)

Add to config/app.php:

```
...
'aliases' => [
    ...
    'Tenant' => Protosofia\Ben10ant\Facades\TenantFacade::class,
    ...
],
...

```

### Models

[](#models)

This package have 3 types of models:

- **Protosofia\\Ben10ant\\Models\\TenantModel**: This model will always target the *main database*, where is the "tenants" table;
- **Protosofia\\Ben10ant\\Models\\TenantBaseModel**: This model will always target the *current tenant database*, in other words, the current logged user tenant;
- **Protosofia\\Ben10ant\\Models\\TenantAuthenticatableBaseModel**: This model is exactly as *TenantBaseModel*, but implements *Illuminate\\Foundation\\Auth\\User*;

To manage the "tenants" table, you can create a model as below:

```
...
use Protosofia\Ben10ant\Models\TenantModel;

class Tenant extends TenantModel
{
    //
}

```

To have a tenant user (authenticatable), you can create a model as below:

```
...
use Protosofia\Ben10ant\Models\TenantAuthenticatableBaseModel;

class User extends TenantAuthenticatableBaseModel
{
    use Notifiable;
    ...
}

```

To have models to handle tenant data (no authenticatable), you can create a model as below:

```
...
use Protosofia\Ben10ant\Models\TenantBaseModel;

class YourTenantTable extends TenantBaseModel
{
    protected $table = 'your_tenant_table'; //optional
    ...
}

```

Usage
-----

[](#usage)

### Config

[](#config)

```
php artisan vendor:publish

```

This will publish the config file.

### Console Commands

[](#console-commands)

#### Create a New Tenant

[](#create-a-new-tenant)

```
tenant:create {name} {keyname}

```

- name Name of the Tenant. E.g. 'Tenant Alpha';
- keyname Tenant nickname for auth (like a subdomain). E.g. 'tenant-alpha';

This command is a tenant creator wizard, you can configure the database connection and storage.

#### Run Migrations on Tenant Database

[](#run-migrations-on-tenant-database)

```
tenant:migrate {tenant} {--force} {--path} {--pretend} {--step}

```

- tenant Tenant keyname. E.g. 'tenant-alpha';
- --force Force the operation to run when in production;
- --path The path of migrations files to be executed.
- --pretend Dump the SQL queries that would be run.
- --step Force the migrations to be run so they can be rolled back individually.

This command is an indirect call to 'migrate' command, it set tenant conenction automatically. If the path option is not defined it assumes default path: database/migrations/tenants.

#### Refresh and Run Migrations on Tenant Database

[](#refresh-and-run-migrations-on-tenant-database)

```
tenant:migrate:refresh {tenant} {--force} {--path} {--seed} {--seeder} {--step}

```

- tenant Tenant keyname. E.g. 'tenant-alpha';
- --force Force the operation to run when in production;
- --path The path of migrations files to be executed.
- --seed Indicates if the seed task should be re-run.
- --seeder The class name of the root seeder.
- --step The number of migrations to be reverted &amp; re-run.

This command is an indirect call to 'migrate:refresh' command, it set tenant conenction automatically. If the path option is not defined it assumes default path: database/migrations/tenants.

#### Rollback a Migrations on Tenant Database

[](#rollback-a-migrations-on-tenant-database)

```
tenant:migrate:rollback {tenant} {--force} {--path} {--seed} {--seeder} {--step}

```

- tenant Tenant keyname. E.g. 'tenant-alpha';
- --force Force the operation to run when in production;
- --path The path of migrations files to be executed.
- --pretend Dump the SQL queries that would be run.
- --step The number of migrations to be reverted.

This command is an indirect call to 'migrate:rollback' command, it set tenant conenction automatically. If the path option is not defined it assumes default path: database/migrations/tenants.

#### Seed a Tenant Database

[](#seed-a-tenant-database)

```
tenant:db:seed {tenant} {--force} {--class}

```

- tenant Tenant keyname. E.g. 'tenant-alpha';
- --force Force the operation to run when in production;
- --class The class name of the root seeder \[default: "DatabaseSeeder"\]

This command is an indirect call to 'db:seed' command, it set tenant conenction automatically. If the class option is not defined it assumes default class: DatabaseSeeder.

### Middleware

[](#middleware)

There are 3 middlewares available on the package:

- Protosofia\\Ben10ant\\Middlewares\\CheckTenantByID: Get value from header TENANT and try to match the tenant pk database record;
- Protosofia\\Ben10ant\\Middlewares\\CheckTenantByKey: Get value from header TENANT and try to match the tenant keyname database record;
- Protosofia\\Ben10ant\\Middlewares\\CheckTenantByUUID: Get value from header TENANT and try to match the tenant uuid database record;

### Singleton Service / Facade

[](#singleton-service--facade)

The service is a singleton, accessible from a Facade Tenant. E.g:

```
...
use Tenant;

$tenant = Tenant::setTenantByUUID($uuid);

if (!$tenant) {
    return response()->json(['error' => 'No tenant found.'], 404);
}
...

```

The service has 4 methods to set tenant:

- setTenantByID($id) - Set tenant by pk;
- setTenantByUUID($uuid) - Set tenant by uuid;
- setTenantByKey($key) - Set tenant by keyname;
- setTenant(TenantModelInterface $tenant) - Set tenant with a Tenant model instance;

TODO
----

[](#todo)

- Console command to create tenant - Done
    - Database config - Done
    - Storage config - Done
- Console command to migrate tenant - Done
    - Migrate - Done
    - Refresh and Migrate - Done
- Console command to seed a tenant - Done
- Middleware for auth - Done
- Service Provider for Singleton Tenant Service and Facade - Done
- Database migrations (Main database, where all tenants are stored) - Done
- Tenant model - Done

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity68

Established project with proven stability

 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 ~110 days

Recently: every ~4 days

Total

7

Last Release

2692d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7841433?v=4)[ephiot](/maintainers/ephiot)[@ephiot](https://github.com/ephiot)

---

Top Contributors

[![ephiot](https://avatars.githubusercontent.com/u/7841433?v=4)](https://github.com/ephiot "ephiot (34 commits)")

### Embed Badge

![Health badge](/badges/protosofia-ben10ant/health.svg)

```
[![Health](https://phpackages.com/badges/protosofia-ben10ant/health.svg)](https://phpackages.com/packages/protosofia-ben10ant)
```

###  Alternatives

[laravel/octane

Supercharge your Laravel application's performance.

4.0k24.7M205](/packages/laravel-octane)[unopim/unopim

UnoPim Laravel PIM

10.5k2.2k](/packages/unopim-unopim)[nasirkhan/laravel-starter

A CMS like modular Laravel starter project.

1.4k2.7k](/packages/nasirkhan-laravel-starter)[ecotone/laravel

Ecotone for Laravel — CQRS, Event Sourcing, Sagas, Durable Workflows, and Outbox on top of Laravel Queue, via PHP attributes.

21313.7k3](/packages/ecotone-laravel)[codewithdennis/larament

Larament is a time-saving starter kit to quickly launch Laravel 13.x projects. It includes FilamentPHP 5.x pre-installed and configured, along with additional tools and features to streamline your development workflow.

3911.7k](/packages/codewithdennis-larament)[r2luna/brain

Brain: A process-driven architecture alternative for your Laravel Application.

6333.0k1](/packages/r2luna-brain)

PHPackages © 2026

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