Download the PHP package 16bit/easy-multitenancy without Composer
On this page you can find all versions of the php package 16bit/easy-multitenancy. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download 16bit/easy-multitenancy
More information about 16bit/easy-multitenancy
Files in 16bit/easy-multitenancy
Package easy-multitenancy
Short Description Drop-in plugin to enable multitenancy based on SQLite dbs
License MIT
Homepage https://github.com/16bitsrl/easy-multitenancy
Informations about the package easy-multitenancy
Easy Multitenancy for Laravel
A simple, drop-in Laravel package for database-per-tenant multitenancy using SQLite. Perfect for SaaS applications where each tenant gets their own isolated SQLite database with automatic URL-based tenant identification and seamless database switching.
Installation
You can install the package via composer:
Publish the config file:
This is the contents of the published config file:
Features
- Database-per-tenant architecture using SQLite
- Automatic route prefixing with tenant identification
- Seamless database switching based on URL
- Tenant-isolated storage, cache, and sessions
- Automatic tenant injection for queued jobs
- Artisan commands for tenant management
- Events for tenant lifecycle hooks
- Custom URL generator for tenant-aware routing
Usage
Creating a Tenant
Listing Tenants
Running Migrations
Seeding Databases
Accessing Tenants in Code
The package automatically identifies tenants from the URL and switches the database context. All routes are automatically prefixed with {tenant} parameter.
Events
The package dispatches several events you can listen to:
Central (Landlord) Connection
Some data is shared across all tenants (e.g. the list of tenants, global users, billing). Enable the optional central connection to keep the landlord database reachable even while a tenant connection is active:
When enabled, a central connection is registered pointing at your application's default
connection as configured at boot. Add the UsesCentralConnection trait to any model that must
always query the central database, regardless of the current tenant:
Storage note: when storage isolation is enabled the package routes the default filesystem disk to a per-tenant directory (and registers a
tenantdisk). Calls that target the default disk are tenant-scoped; explicitStorage::disk('local')calls are not.
Central Routes
Declare landlord routes that must never be tenant-prefixed (marketing pages, tenant sign-up,
the landlord dashboard) with Tenant::centralRoutes():
These routes keep their original URI (no {tenant}/ prefix), run on the default/central
connection, and are skipped by tenant identification.
Recently Visited Tenants
Enable track_recent_tenants to keep a per-browser list of recently visited tenants in a shared
cookie. Read it (typically from a central route) with Tenant::getRecentTenants():
Queued Jobs
When queue.tenant_aware is enabled (default), the current tenant is automatically injected into
every queued job at dispatch and restored before the job runs — no trait required. Opt a job out of
tenant context by implementing the GlobalJob interface, listing it under queue.excluded_jobs /
queue.excluded_patterns, or setting a public $tenantAware = false property:
Route Configuration
By default, all routes are automatically prefixed with the tenant parameter. You can exclude specific routes:
Generating URLs
The package includes a custom URL generator that automatically includes the tenant parameter:
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Security Vulnerabilities
If you discover a security vulnerability, please email Mattia Trapani at [email protected].
Credits
- Mattia Trapani
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of easy-multitenancy with dependencies
illuminate/console Version ^12.0||^13.0
illuminate/contracts Version ^12.0||^13.0
illuminate/database Version ^12.0||^13.0
illuminate/routing Version ^12.0||^13.0
illuminate/support Version ^12.0||^13.0
spatie/laravel-package-tools Version ^1.16