Tenant isolation
How host, path, and callback resolution select a tenant context.
On this page
Resolve a tenant
Tenancy is disabled by default. Configure it in user/config/tenancy.php; supported resolvers are host, path, and callback.
A host mapping can look like this:
<?php
return [
'enabled' => true,
'default' => 'default',
'resolver' => 'host',
'host' => [
'map' => [
'alpha.example.com' => 'alpha',
'beta.example.com' => 'beta',
],
],
];
The HTTP entry point bootstraps the tenant before booting the application. Path resolution uses a configured segment; callback resolution delegates to a resolver class.
Scope application resources
Loom exposes tenant-aware content, views, storage, cache, sessions, and database configuration. Use the framework path helpers when locating tenant resources. Hardcoded paths to shared directories bypass that resource selection.
The default tenant-specific roots are user/tenants and storage/tenants. Shared application resources and tenant overrides are separate; review the configured roots before provisioning a tenant.
Separate databases when needed
Database-per-tenant mode is an additional option under tenancy.database. It is disabled by default. Configure a database name pattern or explicit tenant mapping when enabling it.
Selecting a tenant does not create your schemas or move existing application data. Provision databases and run the appropriate migrations as part of deployment.
Run commands in context
php loom diagnose --tenant=alpha
The CLI supports tenant context through --tenant. Use --all-tenants only for commands designed to process every tenant, such as the tenancy migration workflow.
See the complete configuration before enabling tenancy in an application.