@extends('_layouts.master') @section('content')
A flexible multi-tenancy package for Laravel. Single & multi-database tenancy, automatic & manual mode, event-based architecture. Integrates perfectly with other packages.
stancl/tenancy is a flexible multi-tenancy Laravel package that comes with lots of features out-of-the-box and doesn't stand in your way when you need anything custom.
Instead of forcing you to change how you write your code, the package by default bootstraps tenancy automatically, in the background. Database connections are switched, caches are separated, filesystems are prefixed, etc.
Out of the box, the package makes the following things tenant-aware: databases, caches, filesystems, queues, redis stores. This means that if you've already written your app and are looking to make it multi-tenant, you don't have to change anything!
Since the automatic mode changes the default database connection, most other packages will use this connection too. This means that you can do awesome things such as using Laravel Nova inside the tenant application to manage the tenant's resources.
Many other tenancy packages have a terrible track record when it comes to testability. We find that unacceptable. With this package, you can test everything. The central application, the tenant application, and everything in between — including the tenant registration flow.
Version 3 is heavily focused on flexibility, but without sacrificing features. Even though everything is customizable, the defaults will likely suit you for the large part.
All of the tenancy bootstrapping logic, post-tenant-creation logic, and most other things, happen as a result of events firing. You can customize every single bit.
Don't want to use the database-per-tenant approach? No problem, we provide you with model traits for scoping models to the current tenant, including models that aren't related to the tenant directly.
Prefer specifying database connections instead of changing the default connection? No problem, we have model traits prepared.
This package has the most features out of all multi-tenancy packages for Laravel.
Need to use the database-per-tenant approach but also need to have users that belong to multiple tenants? We've got you covered. Our Resource Syncing feature lets you synchronize any database resources between specific tenants' databases.
Want to impersonate a user inside a tenant's database from the central context? Or even from another tenant's context? Just enable the user impersonation feature in the config.
Need to separate tenant databases on MySQL/PostgreSQL/SQLite? No problem. Or maybe you want to use PostgreSQL schemas instead? We can do that too.
Apart from saving you a huge amount of time, the automatic mode has another great side effect: it lets you integrate almost any other package with no issues. No more model traits!
This package powers many production applications on many different hosting platforms.
“Tenancy for Laravel allowed us to effortlessly and quickly integrate the needed landlord/tenant functionality for our SaaS platform. It fits our needs perfectly.”
“This package enabled us to abstract all the context switching to focus our development efforts elsewhere. That resulted in significant performance increase. The event driven architecture is powerful, flexible and bends to all our needs.”
Want updates about big releases and product launches?
Sign up for our newsletter.
Yes! The package is in its third major version and has been stable since February 2019. Many people are using it in production.