misaf/vendra-tenant

Multi-tenancy management system with isolated data and configuration per tenant

Maintainers

Package info

github.com/misaf/vendra-tenant

Type:vendra-module

pkg:composer/misaf/vendra-tenant

Transparency log

Statistics

Installs: 12

Dependents: 1

Suggesters: 0

Stars: 1

Open Issues: 0

v1.7.1 2026-07-22 21:54 UTC

This package is auto-updated.

Last update: 2026-07-28 22:08:14 UTC


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-support
  • spatie/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.