PHPackages                             spatie/laravel-multitenancy - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. spatie/laravel-multitenancy

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

spatie/laravel-multitenancy
===========================

Make your Laravel app usable by multiple tenants

4.1.0(2mo ago)1.3k2.9M—6.7%176[1 issues](https://github.com/spatie/laravel-multitenancy/issues)15MITPHPPHP ^8.2CI passing

Since May 5Pushed 2mo ago27 watchersCompare

[ Source](https://github.com/spatie/laravel-multitenancy)[ Packagist](https://packagist.org/packages/spatie/laravel-multitenancy)[ Docs](https://github.com/spatie/laravel-multitenancy)[ Fund](https://spatie.be/open-source/support-us)[ GitHub Sponsors](https://github.com/spatie)[ RSS](/packages/spatie-laravel-multitenancy/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (9)Versions (69)Used By (15)

 [   ![Logo for laravel-multitenancy](https://camo.githubusercontent.com/4253702625190c3427695ddc3e8f3bcfaa1962e6763b6338c619bec7e42f44a2/68747470733a2f2f7370617469652e62652f7061636b616765732f6865616465722f6c61726176656c2d6d756c746974656e616e63792f68746d6c2f6c696768742e776562703f31)  ](https://spatie.be/open-source?utm_source=github&utm_medium=banner&utm_campaign=laravel-multitenancy)Unopinionated multitenancy package for Laravel
==============================================

[](#unopinionated-multitenancy-package-for-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/2119199187ed96a9062c85ed99e12f518c3d1c9b4a35c3079d324e384b4df3f4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7370617469652f6c61726176656c2d6d756c746974656e616e63792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/laravel-multitenancy)[![GitHub Tests Action Status](https://camo.githubusercontent.com/32e54d3c7c0932c35993a25490fc30d3f2d5edf9dc954cd25236ff0670603ff6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7370617469652f6c61726176656c2d6d756c746974656e616e63792f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d5465737473267374796c653d666c61742d737175617265)](https://github.com/spatie/laravel-multitenancy/actions?query=workflow%3Arun-tests+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/70da06419a2ae18937a18c6e445f9f0470201006cd5d3d691806126260a112bd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7370617469652f6c61726176656c2d6d756c746974656e616e63792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/laravel-multitenancy)

This package can make a Laravel app tenant aware. The philosophy of this package is that it should only provide the bare essentials to enable multitenancy.

The package can determine which tenant should be the current tenant for the request. It also allows you to define what should happen when switching the current tenant to another one. It works for multitenancy projects that need to use one or multiple databases.

Before starting with the package, we highly recommend first watching [this talk by Tom Schlick on multitenancy strategies](https://tomschlick.com/laracon-2017-multi-tenancy-talk/).

The package contains a lot of niceties such as making queued jobs tenant aware, making an artisan command run for each tenant, an easy way to set a connection on a model, and much more.

Are you a visual learner? Then watch [this video](https://spatie.be/videos/laravel-package-training/laravel-multitenancy) that covers how you can use laravel-multitenancy and how it works under the hood.

Support us
----------

[](#support-us)

[![](https://camo.githubusercontent.com/5e88f64a8be9f33edcdefd6d3dfacd238e404b2726a4660432ac28cd32423779/68747470733a2f2f6769746875622d6164732e73332e65752d63656e7472616c2d312e616d617a6f6e6177732e636f6d2f6c61726176656c2d6d756c746974656e616e63792e6a70673f743d31)](https://spatie.be/github-ad-click/laravel-multitenancy)

We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).

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

[](#documentation)

You can find the entire documentation for this package [on our documentation site](https://docs.spatie.be/laravel-multitenancy).

Testing
-------

[](#testing)

You'll need to create the following 3 local MySql databases to be able to run the test suite:

- `laravel_mt_landlord`
- `laravel_mt_tenant_1`
- `laravel_mt_tenant_2`

You can run the package's tests:

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you've found a bug regarding security please mail  instead of using the issue tracker.

Credits
-------

[](#credits)

The code of this package is based on the code shown in [the Multitenancy in Laravel series](https://www.youtube.com/watch?v=592EgykFOz4) by Mohamed Said

- [Freek Van der Herten](https://github.com/freekmurze)
- [All Contributors](../../contributors)

Alternatives
------------

[](#alternatives)

- [tenancy/tenancy](https://tenancy.dev)
- [stancl/tenancy](https://tenancyforlaravel.com)
- [gecche/laravel-multidomain](https://github.com/gecche/laravel-multidomain)
- [romegadigital/multitenancy](https://github.com/romegasoftware/multitenancy)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

73

—

ExcellentBetter than 100% of packages

Maintenance83

Actively maintained with recent releases

Popularity68

Solid adoption and visibility

Community43

Growing community involvement

Maturity83

Battle-tested with a long release history

 Bus Factor2

2 contributors hold 50%+ of commits

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

Total

65

Last Release

86d ago

Major Versions

1.8.1 → 2.0.02021-03-12

v1.x-dev → 2.1.12021-08-18

2.3.9 → 3.0.02022-10-31

v2.x-dev → 3.0.12023-02-03

v3.x-dev → 4.0.02024-07-24

PHP version history (4 changes)0.0.1PHP ^7.4

1.6.11PHP ^8.0|^7.4

2.0.0PHP ^8.0

3.2.0PHP ^8.2

### Community

Maintainers

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

---

Top Contributors

[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (342 commits)")[![masterix21](https://avatars.githubusercontent.com/u/6555012?v=4)](https://github.com/masterix21 "masterix21 (224 commits)")[![AlexVanderbist](https://avatars.githubusercontent.com/u/6287961?v=4)](https://github.com/AlexVanderbist "AlexVanderbist (26 commits)")[![moisish](https://avatars.githubusercontent.com/u/15047879?v=4)](https://github.com/moisish "moisish (9 commits)")[![riasvdv](https://avatars.githubusercontent.com/u/3626559?v=4)](https://github.com/riasvdv "riasvdv (9 commits)")[![AdrianMrn](https://avatars.githubusercontent.com/u/12762044?v=4)](https://github.com/AdrianMrn "AdrianMrn (8 commits)")[![telkins](https://avatars.githubusercontent.com/u/53731?v=4)](https://github.com/telkins "telkins (7 commits)")[![igorbabko](https://avatars.githubusercontent.com/u/9337772?v=4)](https://github.com/igorbabko "igorbabko (7 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (6 commits)")[![juukie](https://avatars.githubusercontent.com/u/2678657?v=4)](https://github.com/juukie "juukie (5 commits)")[![jacobmllr95](https://avatars.githubusercontent.com/u/2737132?v=4)](https://github.com/jacobmllr95 "jacobmllr95 (4 commits)")[![jimirobaer](https://avatars.githubusercontent.com/u/8984769?v=4)](https://github.com/jimirobaer "jimirobaer (3 commits)")[![inmanturbo](https://avatars.githubusercontent.com/u/47095624?v=4)](https://github.com/inmanturbo "inmanturbo (3 commits)")[![Joel-Jensen](https://avatars.githubusercontent.com/u/60270137?v=4)](https://github.com/Joel-Jensen "Joel-Jensen (3 commits)")[![drasko95](https://avatars.githubusercontent.com/u/6236041?v=4)](https://github.com/drasko95 "drasko95 (3 commits)")[![Nielsvanpach](https://avatars.githubusercontent.com/u/10651054?v=4)](https://github.com/Nielsvanpach "Nielsvanpach (3 commits)")[![miclf](https://avatars.githubusercontent.com/u/3188746?v=4)](https://github.com/miclf "miclf (3 commits)")[![anthonypeck](https://avatars.githubusercontent.com/u/59670848?v=4)](https://github.com/anthonypeck "anthonypeck (2 commits)")[![ricardov03](https://avatars.githubusercontent.com/u/2243870?v=4)](https://github.com/ricardov03 "ricardov03 (2 commits)")[![Rigby90](https://avatars.githubusercontent.com/u/575561?v=4)](https://github.com/Rigby90 "Rigby90 (2 commits)")

---

Tags

laravelmultitenancyphpspatielaravel-multitenancy

###  Code Quality

TestsPest

### Embed Badge

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

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

###  Alternatives

[spatie/laravel-data

Create unified resources and data transfer objects

1.8k28.9M627](/packages/spatie-laravel-data)[spatie/laravel-cookie-consent

Make your Laravel app comply with the crazy EU cookie law

1.5k4.7M20](/packages/spatie-laravel-cookie-consent)[spatie/laravel-livewire-wizard

Build wizards using Livewire

4061.0M4](/packages/spatie-laravel-livewire-wizard)[spatie/laravel-schedule-monitor

Monitor scheduled tasks in a Laravel app

9815.7M9](/packages/spatie-laravel-schedule-monitor)[spatie/laravel-feed

Generate rss feeds

9743.6M28](/packages/spatie-laravel-feed)[spatie/laravel-event-sourcing

The easiest way to get started with event sourcing in Laravel

9003.7M26](/packages/spatie-laravel-event-sourcing)

PHPackages © 2026

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