misaf / vendra-tenant
Multi-tenancy management system with isolated data and configuration per tenant
Requires
- php: ^8.3
- misaf/vendra-support: v1.7.1
- spatie/laravel-activitylog: ^4.12.3
- spatie/laravel-multitenancy: ^4.1.3
- spatie/laravel-package-tools: ^1.93.1
- spatie/laravel-sluggable: ^4.0.2
- staudenmeir/belongs-to-through: ^2.18
- staudenmeir/eloquent-has-many-deep: ^1.22.1
Requires (Dev)
- fakerphp/faker: ^1.24.1
- larastan/larastan: ^3.10.0
- laravel/boost: ^2.4.12
- laravel/pint: ^1.29.3
- misaf/vendra-testing: v1.7.1
- mockery/mockery: ^1.6.12
- nunomaduro/collision: ^8.9.4
- orchestra/testbench: ^11.1
- pestphp/pest: ^4.7.5
- pestphp/pest-plugin-arch: ^4.0.2
- pestphp/pest-plugin-laravel: ^4.1
- pestphp/pest-plugin-profanity: ^4.2.1
- pestphp/pest-plugin-type-coverage: ^4.0.4
- phpstan/extension-installer: ^1.4.3
README
The concrete multi-tenancy provider for Vendra applications, built on Spatie Laravel Multitenancy.
Installing this package activates tenant awareness across domain packages by
binding the shared TenantResolver contract to VendraTenantResolver. Domain
packages remain coupled only to misaf/vendra-support.
Features
- Tenant and tenant-domain models
- Domain-based tenant discovery
- Application and mail configuration switch tasks
- Per-tenant route caches
- Provisioning state and request-accessibility scopes
- Active-domain replacement with retained domain history
- Loopback-only Caddy on-demand TLS domain authorization
- Recovery command for domain tables migrated before tenancy was enabled
Requirements
- PHP 8.3+
- Laravel 13
misaf/vendra-supportspatie/laravel-multitenancy
Installation
composer require misaf/vendra-tenant php artisan vendor:publish --tag=vendra-tenant-migrations php artisan migrate
Optionally publish the configuration and translations:
php artisan vendor:publish --tag=vendra-tenant-config php artisan vendor:publish --tag=vendra-tenant-translations
Tenant provisioning belongs to the host application. Domain modules discover the active tenant only through the resolver supplied by this package.
config/vendra-tenant.php derives central_host from APP_URL. The registered
GET /caddy/domain-check?domain=… route authorizes only known tenant domains and
only accepts loopback requests; expose it to Caddy through the local reverse
proxy, not directly to the public internet.
Enabling Tenancy After Domain Migrations
If Vendra domain packages were migrated before this provider was installed, create the tenant that should own the existing records and run:
php artisan vendra-tenant:enable {tenant-id-or-slug}
The command consumes the domain table registry, adds missing tenant columns and
indexes on their registered connections, assigns unscoped records to the
selected tenant, and can be rerun safely. Interactive confirmation is enabled
by default; use --force only for intentional non-interactive deployment.
Generate isolated route caches for every tenant with:
php artisan tenants:artisan route:cache
Testing
Run the package checks from the package directory:
composer test
composer analyse
License
MIT. See LICENSE.