azaharizaman / nexus-laravel-tenant-adapter
Laravel adapter for Tenant package with multi-tenant support
Package info
github.com/azaharizaman/nexus-laravel-tenant-adapter
pkg:composer/azaharizaman/nexus-laravel-tenant-adapter
Requires
- php: ^8.3
- azaharizaman/nexus-tenant: dev-main
- illuminate/database: ^11.0|^12.0
- illuminate/support: ^11.0|^12.0
- psr/log: ^3.0
Requires (Dev)
- mockery/mockery: ^1.6
- phpunit/phpunit: ^11.0
This package is auto-updated.
Last update: 2026-05-05 03:44:04 UTC
README
This adapter provides Laravel-specific implementations for the Tenant package, enabling multi-tenant support in Laravel applications.
Purpose
The Tenant package is an atomic package that must remain independently publishable. This adapter layer provides the concrete implementations that integrate Tenant with the Laravel framework:
- Database tenant resolution - Uses Laravel's database layer
- Cache integration - Uses Laravel's cache system
- Event dispatcher - Uses Laravel's event system
Installation
composer require azaharizaman/nexus-laravel-tenant-adapter
Adapters Provided
TenantContextAdapter
Implements Nexus\Tenant\Contracts\TenantContextInterface by resolving the current tenant from Laravel's application context (request, auth, or cache).
TenantPersistenceAdapter
Implements Nexus\Tenant\Contracts\TenantPersistenceInterface by delegating to Laravel's Eloquent ORM for database operations.
TenantQueryAdapter
Implements Nexus\Tenant\Contracts\TenantQueryInterface by using Laravel's query builder for tenant lookups.
CacheRepositoryAdapter
Implements Nexus\Tenant\Contracts\CacheRepositoryInterface by using Laravel's cache system.
EventDispatcherAdapter
Implements Nexus\Tenant\Contracts\EventDispatcherInterface by using Laravel's event dispatcher.
ImpersonationStorageAdapter
Implements Nexus\Tenant\Contracts\ImpersonationStorageInterface by using Laravel's session/cache for storing impersonation tokens.
Service Provider
The TenantAdapterServiceProvider automatically binds the Tenant interfaces to their adapter implementations when the Laravel application boots.
Architecture
This follows the Nexus Three-Layer Architecture:
- Atomic Layer (
packages/Tenant) - Pure business logic, no external dependencies - Adapter Layer (
adapters/Laravel/Tenant) - Framework-specific implementations - Application Layer - Uses adapters through interfaces
Dependencies
azaharizaman/nexus-tenant- The atomic Tenant packageilluminate/support- Laravel framework componentsilluminate/database- Laravel database componentspsr/log- PSR-3 logging interface