Configuration
Filament Tenancy is configured in two equivalent ways: the published config/packstub-tenancy.php file, and a fluent API on TenancyPlugin that mirrors every panel-relevant config key. Fluent calls always win over the config file — the plugin resolves each key from its own overrides first and falls back to config — so you can keep app-wide defaults in the file and override per panel in code. This page is the complete reference: the full annotated config file, the config-key ↔ fluent-method map, a section on every key, and the stancl/tenancy config reference at the end.
The configuration file
Publishing happens during php artisan packstub-tenancy:install (or manually with php artisan vendor:publish --tag=packstub-tenancy-config). This is the full shipped file:
<?php
use Packstub\Tenancy\Filament\Billing\NullBillingProvider;
use Packstub\Tenancy\Filament\Pages\EditPackstubTenantProfile;
use Packstub\Tenancy\Filament\Pages\ManageTenantDomains;
use Packstub\Tenancy\Filament\Pages\OnboardTenant;
use Packstub\Tenancy\Models\Tenant;
return [
'tenant_model' => Tenant::class,
/*
| Which tenant-table columns stay real columns. stancl's virtual column
| packs every other attribute a save touches into the `data` JSON.
|
| - 'shipped' (default): the package's own columns (id, name, slug,
| status, avatar_url, membership.owner_column when set, deleted_at on
| a model with SoftDeletes), as in 1.x. A column you add to the table
| (`plan`) keeps its value in `data`; the model never writes the
| column itself.
| - 'all': every column the tenant table has, read once per process. An
| adopted model's own columns (`personal_team`, an owner `user_id`)
| stay in their columns. `php artisan tenancy:adopt` writes this.
|
| Any other value counts as 'shipped'. After switching an existing
| install to 'all', the values in `data` are still read, and each
| tenant's next save writes them into their columns; created_at,
| updated_at and deleted_at keep their column values (see
| docs/configuration.md).
*/
'tenant_columns' => 'shipped',
/*
| Whether the package's own migrations run automatically (zero-config default).
|
| The migrations already follow the tenant model's table and key type,
| the `membership` pivot and `tenant_columns`. Set this to false only to
| own the schema beyond that (different cascade rules, extra indexes):
| publish the migrations and edit your copies:
|
| php artisan vendor:publish --tag=packstub-tenancy-migrations
|
| Never leave this true after publishing: both copies would register as
| pending migrations and `migrate` would try to create each table twice.
| Note: with auto-run disabled you own the schema — future plugin updates
| that change it will ship upgrade notes instead of applying automatically.
*/
'run_migrations' => true,
/*
| How tenant DATA is separated — the master switch several keys below
| follow.
|
| - 'dedicated' (default): one database per tenant, provisioned on signup
| by the queued CreateDatabase/MigrateDatabase pipeline. Isolation is the
| connection switch itself; tenant tables carry no tenant_id column.
| With the database pool enabled, pool members are database SERVERS and
| each new tenant's database is created on one of them.
|
| - 'shared': tenants share pre-provisioned databases and are isolated by
| a tenant_id relationship scope (scope_resources_to_tenant defaults to
| true). No per-tenant database is created — tenants are ready almost
| instantly. Rows live in the central database by default; with the
| database pool enabled, pool members are shared SHARD databases (each an
| ordinary connection whose `database` already exists and is migrated)
| and new tenants are load-balanced across them.
|
| Per-tenant override for hybrid fleets: create a tenant with an
| `isolation_mode` attribute ('dedicated' | 'shared') to give it the other
| model — e.g. a private database for an enterprise/data-residency tenant
| inside a shared app. See docs/database-strategies.md.
*/
'database_strategy' => 'dedicated',
/*
| The membership pivot between users and tenants.
|
| The shipped schema is `tenant_user` (tenant_id, user_id, role). An app
| that adopts the plugin on top of its own tenant model keeps its pivot
| by naming it here — `team_user` with `team_id`, say. Both membership
| relations (`$tenant->users()`, `$user->tenants()`) and the shipped
| tenant_user migration follow these keys.
|
| Ownership is one bit, kept centrally: "may this user retry a failed
| setup or manage the workspace's domains". It is NOT a permission
| system — roles and permissions inside a tenant belong to Shield /
| spatie/laravel-permission (or Filament Teams), untouched by this block.
|
| - role_column: pivot column holding the membership role; null when
| the pivot has no such column.
| - owner_role: the value that marks an owner in role_column.
| - owner_column: a column ON THE TENANT TABLE holding the owner's user
| id (Jetstream's `teams.user_id`), or null. When set, it alone
| decides ownership, and the owner is reached through the column,
| not a pivot row (Jetstream's convention): `$user->getTenants()`
| merges owned tenants with memberships, and onboarding writes the
| column instead of a pivot row for the creator.
| - timestamps: whether the pivot has created_at / updated_at. A
| hand-rolled pivot without them must say false here, or every
| membership query selects columns that do not exist.
|
| With neither role_column nor owner_column, every member is an owner.
| Override `isOwnedBy($user)` on the tenant model to decide differently
| (e.g. from a Shield role).
*/
'membership' => [
'table' => 'tenant_user',
'tenant_key' => 'tenant_id',
'user_key' => 'user_id',
'role_column' => 'role',
'owner_role' => 'owner',
'owner_column' => null,
'timestamps' => true,
],
'central_domain' => env('TENANCY_CENTRAL_DOMAIN', parse_url((string) env('APP_URL', 'http://localhost'), PHP_URL_HOST)),
/*
| How a request is matched to a tenant. NO stancl middleware to wire in
| either mode — the plugin identifies tenants itself.
| - 'subdomain': full-host domain routing (`{tenant:route_host}`): the
| request host is matched against VERIFIED domain rows,
| covering `{slug}.central_domain` subdomains and (when
| enabled) custom domains.
| - 'path': panel is wired with `->tenantRoutePrefix(route_prefix)`;
| tenants live at /{panel}/{route_prefix}/{slug}.
*/
'identification' => 'subdomain',
'route_prefix' => 'teams',
/*
| Seeder run inside each freshly provisioned tenant database.
|
| Tenant seeding is OPT-IN. Leave this null to skip the seed step entirely
| (the safe default): Stancl's global `tenancy.seeder_parameters` points at
| the CENTRAL Database\Seeders\DatabaseSeeder, which references central-only
| tables/models and would fail — or worse, silently misbehave — against a
| fresh tenant DB. Set this to a tenant-safe seeder class to enable seeding;
| the plugin runs it with --force so queued (non-interactive) workers don't
| prompt in production.
*/
'seeder' => null,
/*
| The relationship name on tenant-aware resources that points to the tenant.
| Leave null to use Filament's default (camelCased basename of the tenant model).
| Mostly relevant when resources are scoped to the tenant (shared strategy).
*/
'ownership_relationship' => null,
/*
| Whether Filament should automatically scope resources to the current
| tenant through the ownership relationship (whereBelongsTo($tenant)).
|
| Default null = follow database_strategy: false under 'dedicated', where
| Stancl's DatabaseTenancyBootstrapper already isolates each tenant on its
| own connection and tenant-DB models have no tenant relationship to scope
| by; true under 'shared', where the tenant_id relationship scope IS the
| isolation. Set an explicit bool to override either way.
*/
'scope_resources_to_tenant' => null,
'menu' => [
'enabled' => true,
'switcher_enabled' => true,
'searchable' => true,
// Array of \Filament\Actions\Action | \Filament\Navigation\MenuItem | Closure
// forwarded verbatim to Panel::tenantMenuItems().
'items' => [],
],
'onboarding' => [
'enabled' => true,
'page' => OnboardTenant::class,
],
'profile' => [
'enabled' => false,
'page' => EditPackstubTenantProfile::class,
],
'billing' => [
'enabled' => false,
'provider' => NullBillingProvider::class,
'route_slug' => 'billing',
'required' => false,
],
'middleware' => [
// Extra persistent middleware appended after EnsureTenantIsReady.
'extra' => [],
],
/*
| Horizontal scaling: load-balance new tenant databases across multiple
| database servers.
|
| Each entry in `connections` is the name of an ordinary connection from
| config/database.php that points at a tenant database server — its host,
| port, admin credentials (CREATE DATABASE privilege), and an existing
| maintenance database on that server. When a tenant is created, the plugin
| picks a member using `strategy` and persists it as the tenant's
| `tenancy_db_connection`; Stancl then provisions, migrates, connects, and
| deletes that tenant on its own server — no further routing needed.
|
| Strategies:
| - 'least-tenants' (default): member with the fewest tenants; self-heals
| after deletions and after a new server joins the pool.
| - 'round-robin': rotate by total pooled-tenant count.
| - 'weighted': fewest tenants per weight unit — give bigger servers a
| larger `weights` entry (missing weights count as 1).
|
| To scale out: add a connection in config/database.php, append its name
| here, deploy (workers too — provisioning runs on the queue). Tenants
| with an explicit `tenancy_db_connection` (e.g. data-residency pins) are
| never reassigned.
|
| Under database_strategy 'shared' the pool means something different:
| each member is a pre-provisioned shared SHARD database (its `database`
| key must name an existing, migrated database), and new shared tenants
| are load-balanced across shards instead of getting their own database.
| See docs/database-strategies.md.
*/
'database_pool' => [
'enabled' => false,
'connections' => [],
'strategy' => 'least-tenants',
'weights' => [],
],
/*
| Shown on the provisioning page when a tenant's setup fails, so users
| land on YOUR support channel. Any URL (https://…, mailto:…).
*/
'support_url' => null,
/*
| In subdomain mode the plugin's global IdentifyTenantHost middleware sets
| the session cookie domain per request host: `.central-domain` on the
| central domain and tenant subdomains (one shared session), host-only on
| verified custom domains. That removes the SESSION_DOMAIN env wiring from
| installs. Set to false to manage `session.domain` yourself.
*/
'manage_session_cookie' => true,
/*
| Custom domains per tenant (subdomain mode only).
|
| When enabled, tenants can attach their own domains (app.acme-corp.com).
| Each domain must pass DNS TXT verification before it identifies the
| tenant. Authentication on custom domains uses a central-login handoff:
| a single-use, short-TTL code minted on the central domain and exchanged
| on the custom domain for a host-only session cookie.
|
| - interstitial: false (default) establishes the session silently;
| true shows a "Continue as …" confirmation on the custom domain.
| - handoff_ttl: seconds a handoff code stays redeemable (hard max 120).
| - handoff_path: path of the landing/exchange endpoint on tenant hosts.
| - verification_prefix: DNS TXT record name prefix; the record
| `{prefix}.{domain}` must contain the token shown in the Domains UI.
*/
'custom_domains' => [
'enabled' => false,
// The tenant-facing Domains page: a page class (extend
// ManageTenantDomains to change its label, icon, slug or access),
// or false for none, with routing and handoff still on.
'page' => ManageTenantDomains::class,
// Where the page sits in the navigation; null keeps the defaults.
'navigation_group' => null,
'navigation_sort' => null,
'cluster' => null,
'interstitial' => false,
'handoff_ttl' => 60,
'handoff_path' => 'auth/handoff',
'verification_prefix' => '_packstub-verify',
],
/*
| Cross-database resource syncing (powered by Stancl\Tenancy\ResourceSyncing).
|
| When enabled, models marked with the SyncsToTenants and IsTenantResource
| traits keep their `synced_attributes` mirrored between the central DB and
| every attached tenant DB.
|
| The plugin equivalents (preferred) are:
| ->syncResources([CentralUser::class => TenantUser::class])
| ->queueResourceSync()
| ->cleanupOrphanedResourceMappings()
*/
'resource_syncing' => [
'enabled' => false,
'pairs' => [],
'queue' => false,
// false | true (default tenant_resources pivot) | ['table' => 'tenant_id_column', ...]
'cleanup' => false,
],
];
Config keys and fluent methods
Every panel-relevant key has a fluent counterpart on TenancyPlugin. A fluent call overrides the config value wholesale for that panel — it does not merge with it. Keys marked "config only" have no fluent method because they are consumed outside the panel (by the service provider, provisioning jobs, or Blade views).
| Config key | Fluent method |
|---|---|
tenant_model |
— (config only) |
tenant_columns |
— (config only) |
run_migrations |
— (config only) |
database_strategy |
->databaseStrategy('dedicated' | 'shared') |
membership.* |
— (config only) |
central_domain |
->centralDomain('example.com') |
identification |
->identification('subdomain' | 'path') |
route_prefix |
->routePrefix('teams') |
seeder |
— (config only) |
ownership_relationship |
->ownershipRelationship('team') |
scope_resources_to_tenant |
->scopeResourcesToTenant() |
menu.enabled |
->withTenantMenu() |
menu.switcher_enabled |
->withTenantSwitcher() |
menu.searchable |
->searchableTenantMenu() |
menu.items |
->tenantMenuItems([...]) |
onboarding.enabled + onboarding.page |
->withTenantRegistration(Page::class) — pass null to disable |
profile.enabled + profile.page |
->withTenantProfile(Page::class) — no argument keeps the shipped page |
billing.* |
->withTenantBilling(Provider::class, routeSlug: 'billing', required: false) |
middleware.extra |
->extraTenantMiddleware([...]) |
database_pool.* |
->databasePool([...], strategy: '...', weights: [...]) — [] disables |
support_url |
— (config only) |
manage_session_cookie |
— (config only) |
custom_domains.enabled |
->customDomains() |
custom_domains.page / navigation_group / navigation_sort / cluster |
->customDomains(page:, group:, sort:, cluster:) |
custom_domains.interstitial |
->handoffInterstitial() |
custom_domains.handoff_ttl / handoff_path / verification_prefix |
— (config only) |
resource_syncing.enabled + resource_syncing.pairs |
->syncResources([Central::class => Tenant::class]) |
resource_syncing.queue |
->queueResourceSync() |
resource_syncing.cleanup |
->cleanupOrphanedResourceMappings() |
A typical fluent setup in your panel provider:
use Packstub\Tenancy\TenancyPlugin;
$panel->plugin(
TenancyPlugin::make()
->identification('path')
->routePrefix('teams')
->databasePool(['tenant_pool_1', 'tenant_pool_2'], strategy: 'least-tenants')
->withTenantProfile()
->extraTenantMiddleware([\App\Http\Middleware\AuditTenantAccess::class]),
);
One exception to "fluent is panel-local": ->databasePool(...) writes its values back into config('packstub-tenancy.database_pool') when the panel boots, so the tenant-creation hook, queued provisioning jobs, and the tenants:pool command all see the same pool the panel was configured with. ->databaseStrategy(...) is mirrored the same way, for the same reason — tenant creation defaults, pool placement, and bootstrapper routing all read it outside the panel.
tenant_model
Default: Packstub\Tenancy\Models\Tenant
The Eloquent model Filament registers as the panel tenant (bound by its slug attribute) and the model the provisioning pipeline, database pool, and HasPackstubTenants trait operate on.
The shipped model extends Stancl's base tenant and already satisfies everything the plugin needs. If you bring your own model, it must meet the same contract:
- implement
Filament\Models\Contracts\HasName,HasAvatar, andHasCurrentTenantLabel— so the tenant switcher shows a real name, avatar (read from theavatar_urlcolumn), and "active tenant" label - implement
Stancl\Tenancy\Database\Contracts\TenantWithDatabaseand use theHasDatabaseandHasDomainstraits — so per-tenant databases and subdomain identification work - use the plugin's
Packstub\Tenancy\Concerns\IsPackstubTenanttrait, which supplies the plugin-specific pieces: the provisioningstatuslifecycle, slug-based route binding, theusers()membership relationship, and the Filament name/avatar/label accessors
use Packstub\Tenancy\Concerns\IsPackstubTenant;
use Stancl\Tenancy\Database\Models\Tenant as StanclTenant;
class Organization extends StanclTenant implements
\Filament\Models\Contracts\HasAvatar,
\Filament\Models\Contracts\HasCurrentTenantLabel,
\Filament\Models\Contracts\HasName,
\Stancl\Tenancy\Database\Contracts\TenantWithDatabase
{
use \Stancl\Tenancy\Database\Concerns\HasDatabase;
use \Stancl\Tenancy\Database\Concerns\HasDomains;
use IsPackstubTenant;
}
Then point the config at it:
'tenant_model' => \App\Models\Organization::class,
There is no fluent method for this key: the service provider registers the database-pool creating hook on the model before any panel boots, so the model must be known from config.
stancl's tenancy.models.tenant follows this key automatically: the plugin sets it at boot whenever the two differ, so a custom model is configured in one place. One exception keeps existing installs as they are: when stancl's key names a subclass of this model, stancl keeps hydrating that subclass. The package migrations follow it too — the tenant table is created under the model's table name, with an auto-increment key when the model increments, and every column that references the tenant key is typed like the table's real key column (a native uuid, an int unsigned from an older increments(), a char(26) ULID, a bigint or a string), so its foreign key is accepted on every engine.
Already have a tenant model in a single-database app? php artisan tenancy:adopt "App\Models\Team" writes this key, tenant_columns, the membership block and the model's declaration for you: Adopting an existing app.
tenant_columns
Default: 'shipped'
stancl's tenant model keeps some attributes in real columns of the tenant table and packs every other attribute a save touches into the data JSON column (stancl's virtual column). This key says which columns are real ones:
'shipped': the package's own columns,id,name,slug,statusandavatar_url, plus themembership.owner_columnwhen you set one, since ownership is queried on that column, and the soft-delete column of a model withSoftDeletes(deleted_at, or what itsgetDeletedAtColumn()returns), whichrestore()writes. This is how 1.x stores tenants, and no schema is read for it. A column you add to the tenant table yourself, sayplan, is read and written throughdata:$tenant->planworks, and the column itself is never written by the model, so it keeps its default. Eloquent still writescreated_atandupdated_atto their columns.'all': every column the tenant table has (read once per process) is a real column.$tenant->planis written toplan, anddatakeeps stancl's own keys and the attributes that have no column of their own (isolation_mode, the pool'stenancy_db_connectionunless you add that column).php artisan tenancy:adoptwrites this, so an adopted model's own columns (personal_team, an owneruser_id) stay where your code and your queries expect them.
Any other value counts as 'shipped', so a typo never stops the app from booting. There is no fluent method: the model reads the key on every save, outside any panel.
Switching an existing install to 'all'
On an install that has run with 'shipped', the values of the columns you added live in data, not in their columns. After the switch the model keeps reading the value in data, and the next save of each tenant writes it into its column and removes it from data. When both hold a value, the one in data wins, because it is the one the model has always read; the exception is the columns Eloquent writes itself (created_at, updated_at, and deleted_at on a model with SoftDeletes), whose column wins, since the copies in data stopped at the save that packed them: updated_at's and deleted_at's always, NULL included (a NULL updated_at is stamped on the next save; the soft-delete scope has always read deleted_at's column), created_at's whenever it is not NULL. The same goes for a long-running queue worker that read the column list before a migration added a column: what it wrote into data reaches the column on the tenant's next save after the restart.
Until a tenant is saved, its column still holds the old value (often the column default), which matters for raw queries, reports and where('plan', ...). It matters the other way too: a value written into the column by a query in that window (a bulk update, DB::table('tenants')->update([...])) is overwritten by the copy in data at the tenant's next save, because data wins. So move the values in a migration of your own first, then switch, and keep query writes to those columns for after the switch. The package ships no such migration: only you know, column by column, whether data or the column holds the value to keep. For a plan column, for example:
use Illuminate\Support\Facades\DB;
DB::table('tenants')->orderBy('id')->chunkById(200, function ($tenants) {
foreach ($tenants as $tenant) {
$data = json_decode((string) $tenant->data, true) ?: [];
if (array_key_exists('plan', $data)) {
DB::table('tenants')->where('id', $tenant->id)->update([
'plan' => $data['plan'],
'data' => json_encode(array_diff_key($data, ['plan' => true])),
]);
}
}
});
Fresh installs and adopted apps have nothing to move: start them on the value you want.
membership
Default:
'membership' => [
'table' => 'tenant_user',
'tenant_key' => 'tenant_id',
'user_key' => 'user_id',
'role_column' => 'role',
'owner_role' => 'owner',
'owner_column' => null,
'timestamps' => true,
],
The pivot between users and tenants. Both membership relations, $tenant->users() and $user->tenants(), and the shipped tenant_user migration read it. An app that keeps its own pivot names it here and nothing is renamed:
'membership' => [
'table' => 'team_user',
'tenant_key' => 'team_id',
'user_key' => 'user_id',
'role_column' => 'role',
'owner_role' => 'owner',
'owner_column' => 'user_id', // Jetstream: teams.user_id is the owner
'timestamps' => true, // false for a pivot without created_at / updated_at
],
The shipped tenant_user migration creates the configured table, with the configured keys and, when role_column is set, that column, and skips it when the table already exists. timestamps => false tells both relations not to select or write created_at / updated_at on a hand-rolled pivot that has neither (tenancy:adopt detects it).
Ownership
Ownership is one bit, kept on the central database: whether a user may retry a failed setup from the provisioning page and manage the workspace's domains. The onboarder stamps it on the user who creates a tenant. isOwnedBy($user) on the tenant model decides it, from this config:
owner_columnset: the column on the tenant table holds the owner's user id, and it alone decides. The owner is reached through the column, not a pivot row, as in Jetstream:getTenants()andcanAccessTenant()merge the tenants the column names (ownedTenants()) with the pivot memberships, and the onboarder writes the column for the creator instead of a pivot row. An app that wants the owner in the pivot as well attaches them in aTenantCreatedlistener.- Otherwise
role_columnset: the user's pivot row carriesowner_role, and the onboarder attaches the creator with it. - Neither: every member is an owner, and the onboarder attaches the creator.
It is not a permission system. The owner check runs on the central database, before any tenant database exists or after provisioning failed, so it cannot live in a tenant's own tables. Roles and permissions inside a tenant belong to spatie/laravel-permission and Filament Shield (per tenant database under dedicated, with Spatie's teams feature keyed by tenant_id under shared), or to Filament Teams. To source the owner bit from there instead, override the method on your model. With spatie/laravel-permission's teams feature and the roles on the central connection (the shared strategy), a role is checked in a team by setting the team id first; hasRole()'s second argument is a guard name, not a team:
use Illuminate\Contracts\Auth\Authenticatable;
public function isOwnedBy(?Authenticatable $user): bool
{
if (! $user || ! method_exists($user, 'hasRole')) {
return false;
}
// Check the role in THIS tenant's team, then put back the team the
// request was using and forget the roles loaded for this one.
$previous = getPermissionsTeamId();
setPermissionsTeamId($this->getKey());
try {
return $user->unsetRelation('roles')->hasRole('owner');
} finally {
setPermissionsTeamId($previous);
$user->unsetRelation('roles');
}
}
There is no fluent method for this block: the relations and the migration read it before any panel boots.
run_migrations
Default: true
Whether the package's own central-database migrations (tenants, tenant_user, domains) run automatically. The default gives you a zero-config install and lets plugin updates ship schema changes with no effort on your side; the shipped migrations already adapt to string tenant keys and your user model's key type.
The migrations follow the configured tenant model and membership block (table names, key type, foreign keys), so a custom or adopted model needs no published copies. Set it to false only when you need to own the schema beyond that — different cascade rules, extra indexes — then publish the migrations and edit your copies:
php artisan vendor:publish --tag=packstub-tenancy-migrations
php artisan migrate
Never leave it true after publishing: both copies would register as pending migrations and migrate would try to create each table twice. With auto-run disabled you own the schema — future releases that change it ship upgrade notes in the changelog instead of applying automatically.
There is no fluent method for this key: migrations are loaded by the service provider before any panel boots.
database_strategy
Default: 'dedicated'
Fluent: ->databaseStrategy('dedicated' | 'shared')
How tenant data is separated — the master switch several other keys follow:
'dedicated'— one database per tenant, provisioned on signup by the queuedCreateDatabase → MigrateDatabase → MarkTenantReadypipeline. Isolation is the connection switch itself; tenant tables carry notenant_idcolumn. With the database pool enabled, pool members are database servers and each new tenant's database is created on one of them.'shared'— tenants share pre-provisioned databases and are isolated by atenant_idrelationship scope (scope_resources_to_tenantdefaults totrue), optionally hardened with PostgreSQL Row-Level Security via stancl'stenants:rlstoolchain. No per-tenant database is created, so tenants are ready almost instantly. Rows live in the central database by default; with the database pool enabled, pool members are shared shard databases and new tenants are load-balanced across them.
Individual tenants can override the app-wide strategy at creation with an isolation_mode attribute ('dedicated' | 'shared'), which is what makes hybrid fleets possible — a private database for one enterprise tenant inside a shared app, or a shared free tier inside a dedicated app.
The full setup for each model — schema, scoping, shards, promotion between modes — is covered in Database strategies.
central_domain
Default: env('TENANCY_CENTRAL_DOMAIN'), falling back to the host of APP_URL
Fluent: ->centralDomain('example.com')
The apex domain tenant subdomains hang off in subdomain mode. With central_domain set to example.com, the tenant acme lives at acme.example.com, and the plugin's identification middleware treats example.com as the central (login/onboarding) origin. Set it explicitly via the TENANCY_CENTRAL_DOMAIN environment variable when your APP_URL host is not the tenant apex, or per panel with the fluent ->centralDomain(). Ignored in path mode.
identification
Default: 'subdomain' — the installer prompt writes your choice into the published config.
How a request is matched to a tenant:
'subdomain'— the panel is wired with full-host domain routing (->tenantDomain('{tenant:route_host}')): the whole request host is matched against the tenant's verified domain rows, which coversacme.{central_domain}subdomains and, when enabled, custom domains. No stancl middleware to add — the plugin registers its own identification middleware globally.'path'— the panel is wired with->tenantRoutePrefix(route_prefix), so tenants live atexample.com/admin/{prefix}/{slug}. Do not addInitializeTenancyByPathto the panel: it throws on tenant-less central routes such as/login. The plugin bridges Filament's resolved tenant into stancl/tenancy automatically (via theTenantSetevent).
The two modes need different surrounding setup (middleware, sessions, config/tenancy.php) — see Installation for the mode-specific checklists.
route_prefix
Default: 'teams'
The URL segment placed before the tenant slug in path mode: example.com/admin/teams/acme. Ignored in subdomain mode.
seeder
Default: null (no seeding)
The seeder class run inside each freshly provisioned tenant database. Tenant seeding is opt-in, and the default is deliberately null: Stancl's global tenancy.seeder_parameters points at your app's central Database\Seeders\DatabaseSeeder, which references central-only tables and would fail — or silently misbehave — against a fresh tenant database, turning every provision into a failure.
When you set a tenant-safe seeder class:
'seeder' => \Database\Seeders\TenantSeeder::class,
the plugin inserts a SeedDatabase step into the provisioning pipeline (CreateDatabase → MigrateDatabase → SeedDatabase → MarkTenantReady) and runs the seeder with --force, so queued, non-interactive workers never hang on a production prompt.
ownership_relationship
Default: null (Filament's default — the camelCased basename of the tenant model)
The relationship name on tenant-aware resources that points at the tenant, passed through to Filament's ->tenant() registration. Only meaningful when resources are scoped to the tenant (the shared strategy, or an explicit scope_resources_to_tenant => true); under the dedicated strategy resources are not scoped by relationship at all.
scope_resources_to_tenant
Default: null (follow database_strategy)
Whether Filament automatically scopes resource queries to the current tenant through the ownership relationship (whereBelongsTo($tenant)).
The default null follows the database strategy: false under 'dedicated', where Stancl's DatabaseTenancyBootstrapper already isolates each tenant on its own database connection — and tenant-DB models have no tenant relationship to scope by, so scoping would break every resource query. true under 'shared', where the tenant_id relationship scope is the isolation — leaving it off there would show every tenant's rows to everyone.
Set an explicit bool only when you need to override the strategy default — e.g. a shared-strategy app that scopes with its own global scopes instead of Filament's.
menu
Defaults: enabled: true, switcher_enabled: true, searchable: true, items: []
Controls Filament's tenant menu in the topbar:
enabled— show or hide the tenant menu entirely (->withTenantMenu(false)to hide).switcher_enabled— show or hide the tenant switcher inside the menu (->withTenantSwitcher(false)).searchable— whether the switcher offers a search input; useful for users who belong to many tenants (->searchableTenantMenu()).items— an array ofFilament\Actions\Action,Filament\Navigation\MenuItem, orClosureentries, forwarded verbatim toPanel::tenantMenuItems(). Because closures don't belong in cached config files, prefer the fluent form:
use Filament\Actions\Action;
TenancyPlugin::make()
->tenantMenuItems([
Action::make('settings')
->url(fn (): string => route('filament.admin.tenant.settings'))
->icon('heroicon-m-cog-8-tooth'),
]);
onboarding
Defaults: enabled: true, page: Packstub\Tenancy\Filament\Pages\OnboardTenant::class
The tenant registration (onboarding) page — where a user creates a new tenant, which kicks off queued database provisioning and lands them on the Livewire-polled provisioning screen. page must be a Filament\Pages\Tenancy\RegisterTenant subclass.
Fluently, one method covers both keys — pass your page class to replace the shipped page, or null to disable registration:
TenancyPlugin::make()->withTenantRegistration(App\Filament\Pages\RegisterOrganization::class);
TenancyPlugin::make()->withTenantRegistration(null); // no self-service tenant creation
profile
Defaults: enabled: false, page: Packstub\Tenancy\Filament\Pages\EditPackstubTenantProfile::class
The tenant profile page — where members edit the current tenant's name and details. Disabled by default. page must be a Filament\Pages\Tenancy\EditTenantProfile subclass.
TenancyPlugin::make()->withTenantProfile(); // enable with the shipped page
TenancyPlugin::make()->withTenantProfile(App\Filament\Pages\EditOrganizationProfile::class);
billing
Defaults: enabled: false, provider: NullBillingProvider::class, route_slug: 'billing', required: false
Wires Filament's tenant billing integration:
provider— aFilament\Billing\Providers\Contracts\BillingProviderclass (or instance, fluently). The shippedNullBillingProvideris a stub that renders a placeholder page; replace it with your real integration.route_slug— the URL slug of the billing route within the tenant panel.required— whentrue, the panel callsrequiresTenantSubscription(), which appends the provider's subscribed middleware to every tenant route so unsubscribed tenants are redirected to billing.
TenancyPlugin::make()->withTenantBilling(
App\Billing\StripeBillingProvider::class,
routeSlug: 'billing',
required: true,
);
Guard: if required is true but the provider's getSubscribedMiddleware() returns an empty string, registration throws a LogicException instead of shipping broken routes — Laravel would otherwise try to resolve '' as a middleware class and 500 on every tenant page. In practice this means the stub NullBillingProvider cannot be used with required billing: a required provider must return the middleware class that actually enforces the subscription.
middleware.extra
Default: []
Extra middleware classes appended to the panel's persistent tenant middleware, after the plugin's EnsureTenantIsReady (which keeps users out of tenants that are still provisioning or failed). Persistent tenant middleware also runs on Livewire update requests, so this is the right place for anything that must hold on every tenant interaction — auditing, feature gating, and the like.
TenancyPlugin::make()->extraTenantMiddleware([
App\Http\Middleware\AuditTenantAccess::class,
]);
database_pool
Defaults: enabled: false, connections: [], strategy: 'least-tenants', weights: []
Horizontal scaling: load-balance new tenant databases across multiple database servers. Each entry in connections names an ordinary connection from config/database.php that points at a tenant database server — host, port, admin credentials with the CREATE DATABASE privilege, and an existing maintenance database on that server. At tenant creation the plugin picks a member using strategy and persists it as the tenant's tenancy_db_connection; Stancl then provisions, migrates, connects, and deletes that tenant on its own server with no further routing.
TenancyPlugin::make()->databasePool(
['tenant_pool_1', 'tenant_pool_2'],
strategy: 'least-tenants',
);
Strategies: least-tenants (default), round-robin, and weighted (pass weights: ['tenant_pool_1' => 2, 'tenant_pool_2' => 1] to give bigger servers more tenants; missing weights count as 1). Tenants with an explicit tenancy_db_connection — for example data-residency pins — are never reassigned by the pool. The pool configuration is validated at boot: undefined or reserved connection names, URL-style connections, a missing database manager for a connection's driver, an unknown strategy, or invalid weights all throw immediately rather than failing at provisioning time.
Monitor the pool with php artisan tenants:pool (add --check for a CI-friendly health exit code) or the Packstub\Tenancy\Filament\Widgets\DatabasePoolOverview dashboard widget.
See Horizontal scaling for the full guide — server prerequisites, scaling out, and operational caveats.
support_url
Default: null
A URL shown on the provisioning page when a tenant's setup fails, so stuck users land on your support channel instead of a dead end. Any URL works — https://support.example.com, mailto:[email protected]. When null, the failure state shows a generic "contact support" message without a link.
manage_session_cookie
Default: true
In subdomain mode the plugin's identification middleware sets the session cookie domain per request host — .central-domain on the central domain and every tenant subdomain (one shared login), host-only on verified custom domains — and mirrors it into the cookie jar so remember-me cookies land on the same domain. This is what removes the SESSION_DOMAIN env wiring from installs. Set to false to take back manual control of session.domain; identification and hygiene redirects keep working either way. No fluent method: the middleware runs globally, outside any panel.
custom_domains
Default: disabled
Fluent: ->customDomains(page:, group:, sort:, cluster:), ->handoffInterstitial()
Lets tenants attach their own DNS-verified domains, served with full-host routing and central-login code handoff. Subdomain mode only — enabling it in path mode throws at registration. The sub-keys:
enabled— turns on the Domains page, thetenants:domainscommand, custom-domain identification, and the handoff endpoints.page— the tenant-facing Domains page:ManageTenantDomains::class(default), your own subclass of it, orfalsefor no page while everything else stays on.navigation_group,navigation_sort,cluster— where the Domains page sits in the panel's navigation;nullkeeps the defaults (no group, sort90, no cluster). See Custom domains → Placing the Domains page.interstitial— show a "Continue as …" confirmation on the custom domain instead of establishing the handed-off session silently.handoff_ttl— seconds a handoff code stays redeemable (default 60, hard-capped at 120).handoff_path— path of the landing/exchange endpoint on tenant hosts (defaultauth/handoff).verification_prefix— DNS TXT record name prefix for ownership proof (default_packstub-verify).
The full feature — verification flow, handoff security model, logout propagation, TLS notes — is documented in Custom domains.
resource_syncing
Defaults: enabled: false, pairs: [], queue: false, cleanup: false
Cross-database resource syncing, powered by Stancl\Tenancy\ResourceSyncing. When enabled, models marked with the plugin's SyncsToTenants (central) and IsTenantResource (tenant) traits keep their synced attributes (declared via a syncedAttributes() method or $syncedAttributes property on the model) mirrored between the central database and every attached tenant database — the canonical example is one central user identity reflected into each tenant DB the user belongs to.
enabled— turns the syncing listeners on.pairs— a map of central model class ⇒ tenant model class. Pairs are informational at registration time (Stancl's listeners react to the contracts on the models themselves), but declaring them enables an extra integrity check at boot and makes the wiring explicit.queue— push the syncing listeners onto the queue; useful when one central change fans out to many tenant databases and blocking the request is undesirable.cleanup— configure the listener that deletes a tenant's pivot mappings when the tenant is deleted.falsedisables it,trueuses Stancl's default polymorphictenant_resourcespivot (the one this plugin ships), or pass['table' => 'tenant_id_column']for additional basic pivots.
The fluent equivalents are preferred in panel apps:
TenancyPlugin::make()
->syncResources([App\Models\User::class => App\Models\TenantUser::class])
->queueResourceSync()
->cleanupOrphanedResourceMappings();
The config keys exist so non-Filament entry points — central-only Artisan workers, for instance — get the same wiring without a panel booting. See Resource syncing for the model contracts and a full walkthrough.
Config merging
When the package registers, it deep-merges its defaults under your published values using array_replace_recursive. This matters because Laravel's standard mergeConfigFrom only merges top-level keys: with shallow merging, publishing a slim config such as 'onboarding' => ['enabled' => true] would silently drop the package's nested onboarding.page default and disable registration. With Filament Tenancy, you can safely publish a trimmed config file containing only the keys you change — every nested default you omit is filled in.
One caveat: a deep merge combines by key, so it can never shrink an array default. If a future release ships a non-empty list-type default (for example, entries in menu.items), you could not remove those entries from the config file alone — you would override the whole array via the fluent API instead, which replaces values wholesale rather than merging. Today every list-type key (menu.items, middleware.extra, resource_syncing.pairs) defaults to [], so this is a forward-looking constraint, not a current limitation.
stancl/tenancy config reference
Filament Tenancy sits on top of stancl/tenancy, which has its own config/tenancy.php. The installer publishes it with the plugin's defaults applied — the tenant model pointed at the package's, DatabaseSessionBootstrapper disabled, and (in path mode) the path resolver's tenant_model_column set to slug. If you'd rather start from stancl's raw file (config only — not its migrations):
php artisan vendor:publish --provider="Stancl\Tenancy\TenancyServiceProvider" --tag=config
…then make those edits by hand. A missed DatabaseSessionBootstrapper edit is harmless at runtime — the plugin strips it — but it shows up as a warning in your log and in php artisan about until you remove it.
The annotated reference below shows every key Filament Tenancy cares about, trimmed to the relevant parts of config/tenancy.php. Keys not shown can keep their published defaults.
<?php
declare(strict_types=1);
use Stancl\Tenancy\Bootstrappers;
use Stancl\Tenancy\Middleware;
use Stancl\Tenancy\Resolvers;
return [
'models' => [
// Must match packstub-tenancy.tenant_model — the shipped model, or
// your own model using the IsPackstubTenant trait.
'tenant' => \Packstub\Tenancy\Models\Tenant::class,
// Leave the published default (stancl's Domain) — the plugin
// upgrades it to \Packstub\Tenancy\Models\Domain automatically, which
// adds ownership verification (verified_at / verification_token) for
// custom domains. Only set this if you bind your own subclass.
'domain' => \Stancl\Tenancy\Database\Models\Domain::class,
// Leave the published default for the shipped model: its tenants
// migration creates a string `id` and the UUIDGenerator fills it. Any
// custom generator returning unique strings also works. For a model
// with an auto-increment key set this to null: the shipped tenants
// migration then creates an auto-increment `id`, and `php artisan
// tenancy:adopt` writes null here for an adopted model whose key
// increments.
'id_generator' => \Stancl\Tenancy\UniqueIdentifierGenerators\UUIDGenerator::class,
],
'identification' => [
// The domains serving your CENTRAL app (login, registration,
// onboarding). In subdomain mode, any host NOT listed here is treated
// as a tenant domain. The default derives the host from APP_URL.
'central_domains' => [
str(env('APP_URL'))->after('://')->before('/')->before(':')->toString(),
],
'default_middleware' => Middleware\InitializeTenancyByDomain::class,
'resolvers' => [
Resolvers\PathTenantResolver::class => [
'tenant_parameter_name' => 'tenant',
// PATH MODE ONLY — REQUIRED. Filament binds the {tenant} route
// parameter by slug; Stancl resolves by primary key by default.
// Without this, path identification looks up the wrong column.
'tenant_model_column' => 'slug',
],
],
],
/*
* Bootstrappers run when tenancy initializes and make Laravel features
* tenant-aware.
*/
'bootstrappers' => [
// REQUIRED. Rewires the default database connection to the tenant's
// database — this is what makes multi-database tenancy work.
Bootstrappers\DatabaseTenancyBootstrapper::class,
// Recommended: prefixes cache keys per tenant.
Bootstrappers\CacheTenancyBootstrapper::class,
// Recommended: per-tenant storage directories.
Bootstrappers\FilesystemTenancyBootstrapper::class,
// Recommended: re-initializes tenancy inside queued jobs.
Bootstrappers\QueueTenancyBootstrapper::class,
// DatabaseSessionBootstrapper stays disabled. Sessions and auth are
// central by design in every mode — see "How it works". A
// tenant-DB session would break login, the tenant switcher, and
// logout revocation. stancl's raw config ships it ENABLED; the
// installer publishes it commented out, and the plugin strips it at
// runtime (with a warning) if it ever comes back.
],
'database' => [
// REQUIRED — Filament Tenancy refuses to boot if this is null or
// empty (it throws a RuntimeException with instructions). The plugin
// pins all central identity — the Tenant model, onboarding and profile
// writes, resource-syncing masters — to this connection; without it,
// those writes would silently land in the ACTIVE (tenant) database.
// The default resolves from DB_CONNECTION, which is fine for most apps.
'central_connection' => env('DB_CONNECTION', 'central'),
// Optional "template" for the dynamically created tenant connection.
// Note: never name a connection "tenant" — that name is reserved.
// If you enable the database pool, pool members act as per-server
// templates instead — see ./horizontal-scaling.md. Template
// connections must be defined as arrays, not DB URLs.
'template_tenant_connection' => null,
// Tenant database names: prefix + tenant key + suffix.
// e.g. 'tenant' . 42 . '' → "tenant42"
'prefix' => 'tenant',
'suffix' => '',
// Which manager creates/drops tenant databases, per driver.
'managers' => [
'sqlite' => \Stancl\Tenancy\Database\TenantDatabaseManagers\SQLiteDatabaseManager::class,
'mysql' => \Stancl\Tenancy\Database\TenantDatabaseManagers\MySQLDatabaseManager::class,
'mariadb' => \Stancl\Tenancy\Database\TenantDatabaseManagers\MySQLDatabaseManager::class,
'pgsql' => \Stancl\Tenancy\Database\TenantDatabaseManagers\PostgreSQLDatabaseManager::class,
'sqlsrv' => \Stancl\Tenancy\Database\TenantDatabaseManagers\MicrosoftSQLDatabaseManager::class,
],
],
/*
* Parameters for tenant migrations. The provisioning pipeline's
* MigrateDatabase job runs migrations from database/migrations/tenant —
* create that directory and put your tenant-database schema there.
* Central tables (users, tenants, domains) stay in database/migrations.
*/
'migration_parameters' => [
'--force' => true,
'--path' => [database_path('migrations/tenant')],
'--realpath' => true,
],
/*
* Leave this alone. Tenant seeding is opt-in via the
* packstub-tenancy.seeder config key: when you set a tenant-safe seeder
* class there, the plugin points Stancl at it (and forces it, so queued
* workers never prompt). When left null, provisioning skips seeding
* entirely instead of running your central DatabaseSeeder against a
* fresh tenant database.
*/
'seeder_parameters' => [],
];
Two rules worth restating — the plugin checks both at boot rather than letting them break the app quietly:
database.central_connectionmust be set. A missing central connection would route central writes into whichever tenant database is active — the plugin throws a clearRuntimeExceptionat boot.DatabaseSessionBootstrappermust not be enabled — in any mode. Sessions and auth live on the central connection by design (see Isolation model). stancl's raw published config enables it; the plugin strips it at runtime regardless and, if your published config lists it, logs a warning and flags it inphp artisan aboutuntil you remove it.
If you plan to scale tenant databases across multiple servers, configure the database pool after finishing this guide — see Horizontal scaling.