Automatic tenancy for your Laravel app

No code changes required.

stancl/tenancy is a package that uses a completely new approach to implementing multi-tenancy.

Instead of forcing you to change how you write your app, it bootstraps tenancy automatically, in the background.

Easy Installation

Two commands is all you need to get started.

composer require stancl/tenancy
php artisan tenancy:install

After installation, just focus on what's important to you — writing your app.

Fully Testable

You can test every single part of your app the same way you test any Laravel application.

Test everything from tenant creation to logic inside the tenant part of the application.

Multi-tenancy doesn't have to mean sacrificing testability.

Awesome Integration

By switching things in the background, the package doesn't stand in your way.

You can integrate with just about any package.


Automatic Data Separation

Tenants' databases, caches, filesystems, queues and Redis stores are automatically separated. You can write your app like you're used to and let the package worry about tenant data separation.

cache()->remember('total_revenue', function () {
    return Order::with('products')
'redis' => [
    'prefix_base' => 'tenant',
    'prefixed_connections' => [


Even though everything happens automatically, you're still in control. You can configure how database names, Redis keys and filesystem paths are prefixed, as well as how cache is tagged and what DB/Redis connections and FS disks are made multi-tenant.


stancl/tenancy comes with artisan commands for migrating, rolling back, as well as seeding tenant databases.

$ artisan tenants:seed --tenants=8075a580-1cb8-11e9-8822-49c5d8f8ff23
Tenant: 8075a580-1cb8-11e9-8822-49c5d8f8ff23 (tenant1.localhost)
Database seeding completed successfully.
class PostgreSQLDatabaseManager implements TenantDatabaseManager
    public function createDatabase($name)

SOLID extensibility

The package follows the SOLID principles and is open to extension. You're free to write (and contribute ❤️) your own Storage Drivers, Tenancy Bootstrappers, and Feature classes.

How it works

Ready to try it?

Just create a new Laravel project and install the package.
Or, install it into your existing project. It will work just as well.

Stay Updated

If you'd like to be notified about new versions and related stuff, you can sign up for e-mail notifications or join our Telegram channel.

Subscribe to e-mail notifications

What would you like to be notified about?