{"id":2763,"date":"2025-08-28T12:25:18","date_gmt":"2025-08-28T12:25:18","guid":{"rendered":"https:\/\/www.vibidsoft.com\/blog\/?p=2763"},"modified":"2026-10-29T02:35:14","modified_gmt":"2026-10-29T02:35:14","slug":"how-to-set-up-multi-tenant-applications-in-laravel-12","status":"publish","type":"post","link":"https:\/\/www.vibidsoft.com\/blog\/how-to-set-up-multi-tenant-applications-in-laravel-12\/","title":{"rendered":"How to Set Up Multi-Tenant Applications in Laravel 12"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Multi-tenancy lets one Laravel application serve many customers (tenants) while keeping each customer&#8217;s data separate. It is the foundation of most SaaS products: one codebase, one deployment, many companies each seeing only their own users, settings and records. This guide explains the three multi-tenancy models, helps you choose the right one, and walks through a working setup in <strong>Laravel 12<\/strong> using both a single database with tenant scoping and the <strong>spatie\/laravel-multitenancy<\/strong> package with a database per tenant.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-multi-tenancy-in-laravel\">What is multi-tenancy in Laravel?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A <strong>tenant<\/strong> is a customer account, such as a company, school or store, that uses your application. In a multi-tenant Laravel app, every request is resolved to one tenant (usually by domain or subdomain), and everything the code does during that request (queries, cache, files, queued jobs) is limited to that tenant.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The opposite is single-tenancy: a separate copy of the application for every customer. That is simple at first but becomes expensive to deploy, update and monitor as you grow.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"the-three-multi-tenancy-models\">The three multi-tenancy models<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Model<\/th><th>How data is separated<\/th><th>Best for<\/th><th>Trade-offs<\/th><\/tr><\/thead><tbody><tr><td>Single database, shared tables<\/td><td>A <code>tenant_id<\/code> column on every tenant-owned table<\/td><td>Many small tenants, MVPs, low cost<\/td><td>A missed scope can leak data; one large database<\/td><\/tr><tr><td>Single database, separate schemas<\/td><td>One PostgreSQL schema per tenant<\/td><td>PostgreSQL apps that need stronger isolation<\/td><td>PostgreSQL-specific; migrations run per schema<\/td><\/tr><tr><td>Database per tenant<\/td><td>Each tenant has its own database<\/td><td>B2B, compliance-heavy or large tenants<\/td><td>More databases to migrate, back up and monitor<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Rule of thumb:<\/strong> start with a single database and <code>tenant_id<\/code> if you expect hundreds or thousands of small tenants. Choose database-per-tenant when customers demand isolation, need their data exported or deleted cleanly, or vary greatly in size.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"option-1-single-database-with-tenant-scoping\">Option 1: single database with tenant scoping<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This approach needs no package. You add a <code>tenant_id<\/code> foreign key to tenant-owned tables and make sure every query is filtered automatically.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"1-create-the-tenants-table-and-add-tenant-id\">1. Create the tenants table and add tenant_id<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>php artisan make:model Tenant -m<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>Schema::create('tenants', function (Blueprint $table) {\n    $table-&gt;id();\n    $table-&gt;string('name');\n    $table-&gt;string('domain')-&gt;unique();\n    $table-&gt;timestamps();\n});\n\nSchema::table('projects', function (Blueprint $table) {\n    $table-&gt;foreignId('tenant_id')-&gt;constrained()-&gt;cascadeOnDelete();\n    $table-&gt;index('tenant_id');\n});<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"2-identify-the-tenant-for-each-request\">2. Identify the tenant for each request<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">A middleware looks up the tenant from the host name and stores it in the container:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>namespace App\\Http\\Middleware;\n\nuse App\\Models\\Tenant;\nuse Closure;\nuse Illuminate\\Http\\Request;\n\nclass IdentifyTenant\n{\n    public function handle(Request $request, Closure $next)\n    {\n        $tenant = Tenant::where('domain', $request-&gt;getHost())-&gt;firstOrFail();\n\n        app()-&gt;instance(Tenant::class, $tenant);\n\n        return $next($request);\n    }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Register it in <code>bootstrap\/app.php<\/code> (Laravel 11 and 12):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>-&gt;withMiddleware(function (Middleware $middleware) {\n    $middleware-&gt;web(append: [\\App\\Http\\Middleware\\IdentifyTenant::class]);\n})<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"3-scope-every-query-automatically\">3. Scope every query automatically<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">A trait adds a global scope and fills <code>tenant_id<\/code> when records are created:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>namespace App\\Models\\Concerns;\n\nuse App\\Models\\Tenant;\nuse Illuminate\\Database\\Eloquent\\Builder;\n\ntrait BelongsToTenant\n{\n    protected static function bootBelongsToTenant(): void\n    {\n        static::addGlobalScope('tenant', function (Builder $query) {\n            if (app()-&gt;bound(Tenant::class)) {\n                $query-&gt;where($query-&gt;getModel()-&gt;getTable() . '.tenant_id', app(Tenant::class)-&gt;id);\n            }\n        });\n\n        static::creating(function ($model) {\n            if (app()-&gt;bound(Tenant::class) &amp;&amp; empty($model-&gt;tenant_id)) {\n                $model-&gt;tenant_id = app(Tenant::class)-&gt;id;\n            }\n        });\n    }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Add <code>use BelongsToTenant;<\/code> to every tenant-owned model. Now <code>Project::all()<\/code> only returns the current tenant&#8217;s projects.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"watch-out-for-these-leaks\">Watch out for these leaks<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Raw queries and the query builder<\/strong> (<code>DB::table()<\/code>) bypass Eloquent global scopes. Add the <code>tenant_id<\/code> condition yourself or avoid raw queries for tenant data.<\/li>\n\n\n<li><strong>Validation rules<\/strong> such as <code>unique<\/code> and <code>exists<\/code> must include the tenant: <code>Rule::unique('projects')-&gt;where('tenant_id', $tenantId)<\/code>.<\/li>\n\n\n<li><strong>Queued jobs and console commands<\/strong> run without an HTTP request, so pass the tenant ID to the job and restore it in <code>handle()<\/code>.<\/li>\n\n\n<li><strong>Cache keys and file paths<\/strong> should be prefixed with the tenant ID.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"option-2-database-per-tenant-with-spatie-laravel-multitenanc\">Option 2: database per tenant with spatie\/laravel-multitenancy<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The <a href=\"https:\/\/github.com\/spatie\/laravel-multitenancy\">spatie\/laravel-multitenancy<\/a> package keeps tenants in a &#8220;landlord&#8221; database and switches the database connection, cache prefix and other settings whenever a tenant becomes current.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"1-install-and-publish-the-config\">1. Install and publish the config<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>composer require spatie\/laravel-multitenancy\nphp artisan vendor:publish --provider=\"Spatie\\Multitenancy\\MultitenancyServiceProvider\" --tag=\"multitenancy-config\"\nphp artisan vendor:publish --provider=\"Spatie\\Multitenancy\\MultitenancyServiceProvider\" --tag=\"multitenancy-migrations\"<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"2-configure-landlord-and-tenant-connections\">2. Configure landlord and tenant connections<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">In <code>config\/database.php<\/code>, define two connections. The <code>tenant<\/code> connection has no database name; the package fills it in for the current tenant.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>'connections' =&gt; [\n    'landlord' =&gt; [\n        'driver' =&gt; 'mysql',\n        'host' =&gt; env('DB_HOST', '127.0.0.1'),\n        'database' =&gt; env('DB_LANDLORD_DATABASE', 'landlord'),\n        'username' =&gt; env('DB_USERNAME'),\n        'password' =&gt; env('DB_PASSWORD'),\n    ],\n    'tenant' =&gt; [\n        'driver' =&gt; 'mysql',\n        'host' =&gt; env('DB_HOST', '127.0.0.1'),\n        'database' =&gt; null,\n        'username' =&gt; env('DB_USERNAME'),\n        'password' =&gt; env('DB_PASSWORD'),\n    ],\n],<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Then in <code>config\/multitenancy.php<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>'tenant_finder' =&gt; \\Spatie\\Multitenancy\\TenantFinder\\DomainTenantFinder::class,\n\n'switch_tenant_tasks' =&gt; [\n    \\Spatie\\Multitenancy\\Tasks\\PrefixCacheTask::class,\n    \\Spatie\\Multitenancy\\Tasks\\SwitchTenantDatabaseTask::class,\n],\n\n'tenant_database_connection_name' =&gt; 'tenant',\n'landlord_database_connection_name' =&gt; 'landlord',\n'queues_are_tenant_aware_by_default' =&gt; true,<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"3-migrate-the-landlord-database\">3. Migrate the landlord database<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>php artisan migrate --path=database\/migrations\/landlord --database=landlord<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>tenants<\/code> table stores each tenant&#8217;s <code>name<\/code>, <code>domain<\/code> and <code>database<\/code>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"4-make-models-use-the-right-connection\">4. Make models use the right connection<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Tenant models use the <code>UsesTenantConnection<\/code> trait; shared models such as plans or the tenant list use <code>UsesLandlordConnection<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>use Spatie\\Multitenancy\\Models\\Concerns\\UsesTenantConnection;\n\nclass Project extends Model\n{\n    use UsesTenantConnection;\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"5-protect-tenant-routes\">5. Protect tenant routes<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>Route::middleware(['web', 'tenant'])-&gt;group(function () {\n    Route::get('\/dashboard', DashboardController::class);\n});<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Define the <code>tenant<\/code> middleware group with the package&#8217;s <code>NeedsTenant<\/code> and <code>EnsureValidTenantSession<\/code> middleware, so a request without a valid tenant is rejected and a user cannot reuse a session on another tenant&#8217;s domain.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"6-run-migrations-for-every-tenant\">6. Run migrations for every tenant<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>php artisan tenants:artisan \"migrate --database=tenant\"<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">When you onboard a new customer, create their database, insert the tenant row in the landlord database, then run the same command for that tenant.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"domains-and-subdomains\">Domains and subdomains<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Subdomains<\/strong> (<code>acme.yourapp.com<\/code>) are easiest: one wildcard DNS record and one wildcard SSL certificate.<\/li>\n\n\n<li><strong>Custom domains<\/strong> (<code>app.acme.com<\/code>) need the customer to point DNS at your servers and an automated way to issue certificates, for example a reverse proxy with automatic TLS or a managed edge service.<\/li>\n\n\n<li>Store every domain on the tenant record so the tenant finder can resolve it.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"production-checklist-for-multi-tenant-laravel-apps\">Production checklist for multi-tenant Laravel apps<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Isolation tests:<\/strong> automated tests that create two tenants and assert one can never read or modify the other&#8217;s data.<\/li>\n\n\n<li><strong>Tenant-aware queues:<\/strong> every job knows its tenant, and failed jobs can be retried in the right context.<\/li>\n\n\n<li><strong>Cache, sessions and storage<\/strong> prefixed or separated per tenant.<\/li>\n\n\n<li><strong>Migrations at scale:<\/strong> run tenant migrations in batches with monitoring, and make migrations backwards compatible during deploys.<\/li>\n\n\n<li><strong>Backups and restores<\/strong> per tenant if you use database-per-tenant, including a tested restore for a single customer.<\/li>\n\n\n<li><strong>Per-tenant limits<\/strong> on API rate, storage and seats, tied to the subscription plan.<\/li>\n\n\n<li><strong>Observability:<\/strong> include the tenant ID in logs and error reports so you can debug one customer quickly.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"which-package-should-you-use\">Which package should you use?<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>spatie\/laravel-multitenancy<\/strong> is deliberately small and unopinionated: it switches context and leaves the rest to you. Good for teams that want control.<\/li>\n\n\n<li><strong>stancl\/tenancy<\/strong> (Tenancy for Laravel) is more automatic: it handles database creation, tenant-aware cache, filesystems and queues out of the box. Good for teams that want more features built in.<\/li>\n\n\n<li><strong>No package<\/strong> (single database with global scopes) is often the simplest choice for early-stage SaaS products.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"frequently-asked-questions\">Frequently asked questions<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Does Laravel 12 support multi-tenancy out of the box?<\/strong> Laravel has no built-in multi-tenancy, but its middleware, global scopes, database connections and queue system make it straightforward to add yourself or with a package.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Single database or a database per tenant?<\/strong> Choose a single database for many small tenants and lower cost. Choose a database per tenant for stronger isolation, large customers or compliance requirements.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Is spatie\/laravel-multitenancy compatible with Laravel 12?<\/strong> Yes, current releases of the package support recent Laravel versions. Check the package&#8217;s composer requirements for your exact version.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>How do I identify tenants by domain?<\/strong> Store each tenant&#8217;s domain and resolve it from the request host, either with your own middleware or the package&#8217;s <code>DomainTenantFinder<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Can queued jobs be tenant aware?<\/strong> Yes. With spatie\/laravel-multitenancy set <code>queues_are_tenant_aware_by_default<\/code> to true; without a package, pass the tenant ID into each job.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"building-a-multi-tenant-saas-on-laravel\">Building a multi-tenant SaaS on Laravel?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Vibidsoft designs and builds multi-tenant Laravel platforms, from tenant onboarding and subscription billing to custom domains and isolation testing. See our <a href=\"https:\/\/www.vibidsoft.com\/laravel-development\">Laravel development services<\/a> and <a href=\"https:\/\/www.vibidsoft.com\/custom-software-development\">custom software development<\/a>, or <a href=\"https:\/\/www.vibidsoft.com\/contact\">talk to our team<\/a> about your SaaS architecture.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Multi-tenancy lets one Laravel application serve many customers (tenants) while keeping each customer&#8217;s data separate. It is the foundation of most SaaS products: one\u2026<\/p>\n","protected":false},"author":6,"featured_media":2764,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"vs_takeaways":"","footnotes":""},"categories":[90,103],"tags":[],"class_list":["post-2763","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-laravel","category-php"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.3 - aioseo.com -->\n\t<meta name=\"description\" content=\"Step-by-step Laravel multi-tenancy guide for Laravel 12: tenancy approaches, spatie\/laravel-multitenancy, identifying tenants by domain and best practices.\" \/>\n\t<meta name=\"robots\" content=\"max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n\t<meta name=\"author\" content=\"Vibidsoft\"\/>\n\t<meta name=\"p:domain_verify\" content=\"147eaec3c09ba1af5e17b00fa12931da\" \/>\n\t<meta name=\"yandex-verification\" content=\"71876bdda9be7264\" \/>\n\t<link rel=\"canonical\" href=\"https:\/\/www.vibidsoft.com\/blog\/how-to-set-up-multi-tenant-applications-in-laravel-12\/\" \/>\n\t\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.3\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"Vibidsoft | Website and Mobile Apps Development Company\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"Laravel Multi-Tenancy Guide: Multi-Tenant Apps in Laravel 12\" \/>\n\t\t<meta property=\"og:description\" content=\"Step-by-step Laravel multi-tenancy guide for Laravel 12: tenancy approaches, spatie\/laravel-multitenancy, identifying tenants by domain and best practices.\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/www.vibidsoft.com\/blog\/how-to-set-up-multi-tenant-applications-in-laravel-12\/\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2025-08-28T12:25:18+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2026-10-29T02:35:14+00:00\" \/>\n\t\t<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/vibidsoft\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/www.vibidsoft.com\/blog\/wp-content\/uploads\/2025\/08\/7-Must-See-Examples-of-Web-Apps-Built-with-Laravel-in-2025-19.jpg\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n\t\t<meta name=\"twitter:site\" content=\"@vibidsoft\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Laravel Multi-Tenancy Guide: Multi-Tenant Apps in Laravel 12\" \/>\n\t\t<meta name=\"twitter:description\" content=\"Step-by-step Laravel multi-tenancy guide for Laravel 12: tenancy approaches, spatie\/laravel-multitenancy, identifying tenants by domain and best practices.\" \/>\n\t\t<meta name=\"twitter:creator\" content=\"@vibidsoft\" \/>\n\t\t<meta name=\"twitter:image\" content=\"https:\/\/www.vibidsoft.com\/blog\/wp-content\/uploads\/2025\/08\/7-Must-See-Examples-of-Web-Apps-Built-with-Laravel-in-2025-19.jpg\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.vibidsoft.com\\\/blog\\\/how-to-set-up-multi-tenant-applications-in-laravel-12\\\/#article\",\"name\":\"Laravel Multi-Tenancy Guide: Multi-Tenant Apps in Laravel 12\",\"headline\":\"How to Set Up Multi-Tenant Applications in Laravel 12\",\"author\":{\"@id\":\"https:\\\/\\\/www.vibidsoft.com\\\/blog\\\/author\\\/webmaster\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/www.vibidsoft.com\\\/blog\\\/#organization\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/www.vibidsoft.com\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/08\\\/7-Must-See-Examples-of-Web-Apps-Built-with-Laravel-in-2025-19.jpg\",\"width\":2240,\"height\":1260,\"caption\":\"How to Set Up Multi-Tenant Applications in Laravel 12\"},\"datePublished\":\"2025-08-28T12:25:18+00:00\",\"dateModified\":\"2026-10-29T02:35:14+00:00\",\"inLanguage\":\"en-US\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.vibidsoft.com\\\/blog\\\/how-to-set-up-multi-tenant-applications-in-laravel-12\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.vibidsoft.com\\\/blog\\\/how-to-set-up-multi-tenant-applications-in-laravel-12\\\/#webpage\"},\"articleSection\":\"Laravel, php\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.vibidsoft.com\\\/blog\\\/how-to-set-up-multi-tenant-applications-in-laravel-12\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.vibidsoft.com\\\/blog\\\/#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.vibidsoft.com\\\/blog\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.vibidsoft.com\\\/blog\\\/category\\\/laravel\\\/#listItem\",\"name\":\"Laravel\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.vibidsoft.com\\\/blog\\\/category\\\/laravel\\\/#listItem\",\"position\":2,\"name\":\"Laravel\",\"item\":\"https:\\\/\\\/www.vibidsoft.com\\\/blog\\\/category\\\/laravel\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.vibidsoft.com\\\/blog\\\/how-to-set-up-multi-tenant-applications-in-laravel-12\\\/#listItem\",\"name\":\"How to Set Up Multi-Tenant Applications in Laravel 12\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.vibidsoft.com\\\/blog\\\/#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.vibidsoft.com\\\/blog\\\/how-to-set-up-multi-tenant-applications-in-laravel-12\\\/#listItem\",\"position\":3,\"name\":\"How to Set Up Multi-Tenant Applications in Laravel 12\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.vibidsoft.com\\\/blog\\\/category\\\/laravel\\\/#listItem\",\"name\":\"Laravel\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.vibidsoft.com\\\/blog\\\/#organization\",\"name\":\"Vibidsoft\",\"description\":\"Website and Mobile Apps Development Company\",\"url\":\"https:\\\/\\\/www.vibidsoft.com\\\/blog\\\/\",\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/vibidsoft\",\"https:\\\/\\\/twitter.com\\\/vibidsoft\",\"https:\\\/\\\/www.instagram.com\\\/vibidsoft\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/vibidsoft\\\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.vibidsoft.com\\\/blog\\\/author\\\/webmaster\\\/#author\",\"url\":\"https:\\\/\\\/www.vibidsoft.com\\\/blog\\\/author\\\/webmaster\\\/\",\"name\":\"Vibidsoft\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/www.vibidsoft.com\\\/blog\\\/how-to-set-up-multi-tenant-applications-in-laravel-12\\\/#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3f9a21a842b31f0dcbb9cc01e368eb5c994b68f9282f9120b7977e3f21f0340e?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"Vibidsoft\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.vibidsoft.com\\\/blog\\\/how-to-set-up-multi-tenant-applications-in-laravel-12\\\/#webpage\",\"url\":\"https:\\\/\\\/www.vibidsoft.com\\\/blog\\\/how-to-set-up-multi-tenant-applications-in-laravel-12\\\/\",\"name\":\"Laravel Multi-Tenancy Guide: Multi-Tenant Apps in Laravel 12\",\"description\":\"Step-by-step Laravel multi-tenancy guide for Laravel 12: tenancy approaches, spatie\\\/laravel-multitenancy, identifying tenants by domain and best practices.\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.vibidsoft.com\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.vibidsoft.com\\\/blog\\\/how-to-set-up-multi-tenant-applications-in-laravel-12\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/www.vibidsoft.com\\\/blog\\\/author\\\/webmaster\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/www.vibidsoft.com\\\/blog\\\/author\\\/webmaster\\\/#author\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/www.vibidsoft.com\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/08\\\/7-Must-See-Examples-of-Web-Apps-Built-with-Laravel-in-2025-19.jpg\",\"@id\":\"https:\\\/\\\/www.vibidsoft.com\\\/blog\\\/how-to-set-up-multi-tenant-applications-in-laravel-12\\\/#mainImage\",\"width\":2240,\"height\":1260,\"caption\":\"How to Set Up Multi-Tenant Applications in Laravel 12\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.vibidsoft.com\\\/blog\\\/how-to-set-up-multi-tenant-applications-in-laravel-12\\\/#mainImage\"},\"datePublished\":\"2025-08-28T12:25:18+00:00\",\"dateModified\":\"2026-10-29T02:35:14+00:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.vibidsoft.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.vibidsoft.com\\\/blog\\\/\",\"name\":\"Vibidsoft\",\"description\":\"Website and Mobile Apps Development Company\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.vibidsoft.com\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Laravel Multi-Tenancy Guide: Multi-Tenant Apps in Laravel 12","description":"Step-by-step Laravel multi-tenancy guide for Laravel 12: tenancy approaches, spatie\/laravel-multitenancy, identifying tenants by domain and best practices.","canonical_url":"https:\/\/www.vibidsoft.com\/blog\/how-to-set-up-multi-tenant-applications-in-laravel-12\/","robots":"max-snippet:-1, max-image-preview:large, max-video-preview:-1","keywords":"","webmasterTools":{"p:domain_verify":"147eaec3c09ba1af5e17b00fa12931da","yandex-verification":"71876bdda9be7264","miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.vibidsoft.com\/blog\/how-to-set-up-multi-tenant-applications-in-laravel-12\/#article","name":"Laravel Multi-Tenancy Guide: Multi-Tenant Apps in Laravel 12","headline":"How to Set Up Multi-Tenant Applications in Laravel 12","author":{"@id":"https:\/\/www.vibidsoft.com\/blog\/author\/webmaster\/#author"},"publisher":{"@id":"https:\/\/www.vibidsoft.com\/blog\/#organization"},"image":{"@type":"ImageObject","url":"https:\/\/www.vibidsoft.com\/blog\/wp-content\/uploads\/2025\/08\/7-Must-See-Examples-of-Web-Apps-Built-with-Laravel-in-2025-19.jpg","width":2240,"height":1260,"caption":"How to Set Up Multi-Tenant Applications in Laravel 12"},"datePublished":"2025-08-28T12:25:18+00:00","dateModified":"2026-10-29T02:35:14+00:00","inLanguage":"en-US","mainEntityOfPage":{"@id":"https:\/\/www.vibidsoft.com\/blog\/how-to-set-up-multi-tenant-applications-in-laravel-12\/#webpage"},"isPartOf":{"@id":"https:\/\/www.vibidsoft.com\/blog\/how-to-set-up-multi-tenant-applications-in-laravel-12\/#webpage"},"articleSection":"Laravel, php"},{"@type":"BreadcrumbList","@id":"https:\/\/www.vibidsoft.com\/blog\/how-to-set-up-multi-tenant-applications-in-laravel-12\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/www.vibidsoft.com\/blog\/#listItem","position":1,"name":"Home","item":"https:\/\/www.vibidsoft.com\/blog\/","nextItem":{"@type":"ListItem","@id":"https:\/\/www.vibidsoft.com\/blog\/category\/laravel\/#listItem","name":"Laravel"}},{"@type":"ListItem","@id":"https:\/\/www.vibidsoft.com\/blog\/category\/laravel\/#listItem","position":2,"name":"Laravel","item":"https:\/\/www.vibidsoft.com\/blog\/category\/laravel\/","nextItem":{"@type":"ListItem","@id":"https:\/\/www.vibidsoft.com\/blog\/how-to-set-up-multi-tenant-applications-in-laravel-12\/#listItem","name":"How to Set Up Multi-Tenant Applications in Laravel 12"},"previousItem":{"@type":"ListItem","@id":"https:\/\/www.vibidsoft.com\/blog\/#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/www.vibidsoft.com\/blog\/how-to-set-up-multi-tenant-applications-in-laravel-12\/#listItem","position":3,"name":"How to Set Up Multi-Tenant Applications in Laravel 12","previousItem":{"@type":"ListItem","@id":"https:\/\/www.vibidsoft.com\/blog\/category\/laravel\/#listItem","name":"Laravel"}}]},{"@type":"Organization","@id":"https:\/\/www.vibidsoft.com\/blog\/#organization","name":"Vibidsoft","description":"Website and Mobile Apps Development Company","url":"https:\/\/www.vibidsoft.com\/blog\/","sameAs":["https:\/\/www.facebook.com\/vibidsoft","https:\/\/twitter.com\/vibidsoft","https:\/\/www.instagram.com\/vibidsoft\/","https:\/\/www.linkedin.com\/company\/vibidsoft\/"]},{"@type":"Person","@id":"https:\/\/www.vibidsoft.com\/blog\/author\/webmaster\/#author","url":"https:\/\/www.vibidsoft.com\/blog\/author\/webmaster\/","name":"Vibidsoft","image":{"@type":"ImageObject","@id":"https:\/\/www.vibidsoft.com\/blog\/how-to-set-up-multi-tenant-applications-in-laravel-12\/#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/3f9a21a842b31f0dcbb9cc01e368eb5c994b68f9282f9120b7977e3f21f0340e?s=96&d=mm&r=g","width":96,"height":96,"caption":"Vibidsoft"}},{"@type":"WebPage","@id":"https:\/\/www.vibidsoft.com\/blog\/how-to-set-up-multi-tenant-applications-in-laravel-12\/#webpage","url":"https:\/\/www.vibidsoft.com\/blog\/how-to-set-up-multi-tenant-applications-in-laravel-12\/","name":"Laravel Multi-Tenancy Guide: Multi-Tenant Apps in Laravel 12","description":"Step-by-step Laravel multi-tenancy guide for Laravel 12: tenancy approaches, spatie\/laravel-multitenancy, identifying tenants by domain and best practices.","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/www.vibidsoft.com\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/www.vibidsoft.com\/blog\/how-to-set-up-multi-tenant-applications-in-laravel-12\/#breadcrumblist"},"author":{"@id":"https:\/\/www.vibidsoft.com\/blog\/author\/webmaster\/#author"},"creator":{"@id":"https:\/\/www.vibidsoft.com\/blog\/author\/webmaster\/#author"},"image":{"@type":"ImageObject","url":"https:\/\/www.vibidsoft.com\/blog\/wp-content\/uploads\/2025\/08\/7-Must-See-Examples-of-Web-Apps-Built-with-Laravel-in-2025-19.jpg","@id":"https:\/\/www.vibidsoft.com\/blog\/how-to-set-up-multi-tenant-applications-in-laravel-12\/#mainImage","width":2240,"height":1260,"caption":"How to Set Up Multi-Tenant Applications in Laravel 12"},"primaryImageOfPage":{"@id":"https:\/\/www.vibidsoft.com\/blog\/how-to-set-up-multi-tenant-applications-in-laravel-12\/#mainImage"},"datePublished":"2025-08-28T12:25:18+00:00","dateModified":"2026-10-29T02:35:14+00:00"},{"@type":"WebSite","@id":"https:\/\/www.vibidsoft.com\/blog\/#website","url":"https:\/\/www.vibidsoft.com\/blog\/","name":"Vibidsoft","description":"Website and Mobile Apps Development Company","inLanguage":"en-US","publisher":{"@id":"https:\/\/www.vibidsoft.com\/blog\/#organization"}}]},"og:locale":"en_US","og:site_name":"Vibidsoft | Website and Mobile Apps Development Company","og:type":"article","og:title":"Laravel Multi-Tenancy Guide: Multi-Tenant Apps in Laravel 12","og:description":"Step-by-step Laravel multi-tenancy guide for Laravel 12: tenancy approaches, spatie\/laravel-multitenancy, identifying tenants by domain and best practices.","og:url":"https:\/\/www.vibidsoft.com\/blog\/how-to-set-up-multi-tenant-applications-in-laravel-12\/","article:published_time":"2025-08-28T12:25:18+00:00","article:modified_time":"2026-10-29T02:35:14+00:00","article:publisher":"https:\/\/www.facebook.com\/vibidsoft","og:image":"https:\/\/www.vibidsoft.com\/blog\/wp-content\/uploads\/2025\/08\/7-Must-See-Examples-of-Web-Apps-Built-with-Laravel-in-2025-19.jpg","twitter:card":"summary_large_image","twitter:site":"@vibidsoft","twitter:title":"Laravel Multi-Tenancy Guide: Multi-Tenant Apps in Laravel 12","twitter:description":"Step-by-step Laravel multi-tenancy guide for Laravel 12: tenancy approaches, spatie\/laravel-multitenancy, identifying tenants by domain and best practices.","twitter:creator":"@vibidsoft","twitter:image":"https:\/\/www.vibidsoft.com\/blog\/wp-content\/uploads\/2025\/08\/7-Must-See-Examples-of-Web-Apps-Built-with-Laravel-in-2025-19.jpg"},"aioseo_meta_data":{"post_id":"2763","title":"Laravel Multi-Tenancy Guide: Multi-Tenant Apps in Laravel 12","description":"Step-by-step Laravel multi-tenancy guide for Laravel 12: tenancy approaches, spatie\/laravel-multitenancy, identifying tenants by domain and best practices.","keywords":null,"keyphrases":{"focus":{"keyphrase":"Laravel 12","score":90,"analysis":{"keyphraseInTitle":{"score":9,"maxScore":9,"error":0},"keyphraseInDescription":{"score":9,"maxScore":9,"error":0},"keyphraseLength":{"score":9,"maxScore":9,"error":0,"length":2},"keyphraseInURL":{"score":5,"maxScore":5,"error":0},"keyphraseInIntroduction":{"score":9,"maxScore":9,"error":0},"keyphraseInSubHeadings":{"score":3,"maxScore":9,"error":1},"keyphraseInImageAlt":[],"keywordDensity":{"type":"best","score":9,"maxScore":9,"error":0}}},"additional":[]},"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":"","og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"Article","isEnabled":true},"graphs":[]},"schema_type":"default","schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":"-1","robots_max_videopreview":"-1","robots_max_imagepreview":"large","priority":null,"frequency":"default","local_seo":null,"breadcrumb_settings":null,"limit_modified_date":false,"ai":{"faqs":[],"keyPoints":[],"titles":[],"descriptions":[],"socialPosts":{"email":[],"linkedin":[],"twitter":[],"facebook":[],"instagram":[]}},"created":"2025-08-28 11:47:08","updated":"2026-10-29 08:00:03","focus_keyword":"Laravel 12","additional_keywords":null,"truseo_locale":null,"seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/www.vibidsoft.com\/blog\/\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/www.vibidsoft.com\/blog\/category\/laravel\/\" title=\"Laravel\">Laravel<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tHow to Set Up Multi-Tenant Applications in Laravel 12\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/www.vibidsoft.com\/blog\/"},{"label":"Laravel","link":"https:\/\/www.vibidsoft.com\/blog\/category\/laravel\/"},{"label":"How to Set Up Multi-Tenant Applications in Laravel 12","link":"https:\/\/www.vibidsoft.com\/blog\/how-to-set-up-multi-tenant-applications-in-laravel-12\/"}],"_links":{"self":[{"href":"https:\/\/www.vibidsoft.com\/blog\/wp-json\/wp\/v2\/posts\/2763","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.vibidsoft.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.vibidsoft.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.vibidsoft.com\/blog\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/www.vibidsoft.com\/blog\/wp-json\/wp\/v2\/comments?post=2763"}],"version-history":[{"count":3,"href":"https:\/\/www.vibidsoft.com\/blog\/wp-json\/wp\/v2\/posts\/2763\/revisions"}],"predecessor-version":[{"id":3005,"href":"https:\/\/www.vibidsoft.com\/blog\/wp-json\/wp\/v2\/posts\/2763\/revisions\/3005"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.vibidsoft.com\/blog\/wp-json\/wp\/v2\/media\/2764"}],"wp:attachment":[{"href":"https:\/\/www.vibidsoft.com\/blog\/wp-json\/wp\/v2\/media?parent=2763"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.vibidsoft.com\/blog\/wp-json\/wp\/v2\/categories?post=2763"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.vibidsoft.com\/blog\/wp-json\/wp\/v2\/tags?post=2763"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}