stancl/tenancy is a tenancy package that uses a completely new approach to multi-tenancy.
Instead of forcing you to change how you write your app, it bootstraps tenancy automatically, in the background.
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')
->get()
->products
->sum();
});
'redis' => [
'prefix_base' => 'tenant',
'prefixed_connections' => [
'default',
],
],
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)
{
//
}
}
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.
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.