PHPackages                             marciojcoelho/multi-tenant - 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. marciojcoelho/multi-tenant

ActiveLibrary[Framework](/categories/framework)

marciojcoelho/multi-tenant
==========================

A simple and lightweight package to craft multi-tenant applications with Laravel.

1.3.7(9y ago)01091MITPHPPHP &gt;=5.5.9

Since May 13Pushed 9y ago1 watchersCompare

[ Source](https://github.com/marciojcoelho/multi-tenant)[ Packagist](https://packagist.org/packages/marciojcoelho/multi-tenant)[ RSS](/packages/marciojcoelho-multi-tenant/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (1)Versions (12)Used By (1)

multi-tenant
============

[](#multi-tenant)

A simple and lightweight package to craft multi-tenant applications with Laravel.

#### Installation

[](#installation)

This package relies on composer as dependency manger. Run the `composer require marciojcoelho/multi-tenant` to install this package. Next add the service provider within `config/app.php`: `Mjc\MultiTenant\MultiTenantServiceProvider::class` in order to be bootstrapped.

#### Defining tenants

[](#defining-tenants)

Tenants are defined in `config/tenant.php`. Make sure to run the `php artisan vendor:publish` command to have this file created. By default, the tenant directories are located at `storage/tenants/{tenantID}`. If you want to use a different base path, override the `path` array key.

```
return [
    'path' => storage_path('tenants'),

    'hosts' => [
        'mysite.com' => [
            'id'    => 'mysite',
            'name'  => 'MySite',
            'https' => true,
        ],
        'anothersite.com' => [
            'id'    => 'anothersite',
            'name'  => 'AnotherSite',
            'https' => false,
            'foo' => 'bar',
        ]
    ]
]

```

In some cases you might want to add custom tenant-specific parameters, like an API key, for instance. Simply use the helper function to retrieve a tenant-specific key value: `tenant('foo')`.

#### Eloquent models

[](#eloquent-models)

In order for your models to deal with multiple connections, simply extend the `TenantModel` class or implement the `HasTenancy` trait. Both classes do exactly the same. Choose the approach you prefer.

#### Migrating and seeding

[](#migrating-and-seeding)

Each tenant has it's own database, which you will want to migrate and seed every once in a while. Define your tenant connections within `config/database.php` and simply add the `--database` parameter to tell artisan which database to choose, for example:

```
php artisan migrate:refresh  --database {tenantConnection} --seed

```

#### Managing assets

[](#managing-assets)

Each tenant has it's own assets which are, by default, stored at `storage/tenants/{tenantID}/assets`. Use the helper function `tasset('foo.svg')` to retrieve a tenant asset. This function will use the route `asset/{path}` to retrieve assets outside the public directory.

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity65

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

Total

12

Last Release

3421d ago

### Community

Maintainers

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

---

Top Contributors

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

---

Tags

laravelmultisitedomains

### Embed Badge

![Health badge](/badges/marciojcoelho-multi-tenant/health.svg)

```
[![Health](https://phpackages.com/badges/marciojcoelho-multi-tenant/health.svg)](https://phpackages.com/packages/marciojcoelho-multi-tenant)
```

###  Alternatives

[hemp/presenter

Easy Model Presenters in Laravel

247608.3k1](/packages/hemp-presenter)[rahulalam31/laravel-abuse-ip

Block ip address of all spammer's around the world.

27234.5k](/packages/rahulalam31-laravel-abuse-ip)[glhd/linen

21439.7k](/packages/glhd-linen)[oleglfed/laravel-ddd

Generates domains for laravel Domain Driven Development

221.3k](/packages/oleglfed-laravel-ddd)

PHPackages © 2026

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