Database per tenant, with automatic database creation and tenant migrations when a tenant is created
tenancy-starterkit — Laravel SaaS Template
By danihidayatx
A Laravel-based multi-tenant SaaS starter kit that integrates stancl/tenancy with a Filament central admin panel and includes tenant, subscription, and billing management.
Explore the design
Compare the page layouts and mobile experience. Open any screenshot for a closer look.
Actual screenshot captured by the server browser.
All pages & views 2
Screenshots show visual appearance; interactive behavior may differ.
What stands out
A quick read of the recorded project description.
Tenants identified by domain or subdomain, with filesystem, cache, queue, and Redis isolated per tenant
Filament central admin panel for managing tenants, subscription plans, subscription status, and billing
Integrated Filament Shield for role-based fine-grained access control
Separate central and tenant model, migration, and route structures, with the tenant side left as an empty template for extension
Built-in Pest test skeleton covering the tenant lifecycle, subscriptions, billing, and user management
Template Details
This is a Laravel starter kit for multi-tenant SaaS, centered on the "database per tenant" model provided by stancl/tenancy: creating a tenant automatically creates the database, runs tenant migrations, and writes the domain record. Tenants are identified by domain or subdomain, and the filesystem, cache, queue, and Redis are all isolated per tenant. The central admin side is built with Filament, allowing tenants to be created, updated, and deleted from the panel, subscription plans to be managed, subscription status to be tracked, and invoices to be generated, with access control integrated via Filament Shield. The project includes a Pest test skeleton covering central features such as the tenant lifecycle, subscriptions, billing, and user management; the tenant side has only a basic load test. The code structure separates the central context (App\Models\Central, including User, Tenant, Domain, Plan, Subscription, and Invoice) from the tenant context (App\Models\Tenant, currently an empty template), and routes are split into routes/web.php and routes/tenant.php. The README uses Stripe as an example to explain how to create a Tenant record via webhook after a successful payment, thereby triggering the automatic provisioning flow, but that integration is not included in the repository; you need to install Laravel Cashier yourself and write the controller and frontend purchase page. The project is MIT licensed and can be used, modified, and commercialized for free, but third-party assets such as demo images, fonts, and icons require separate license verification, and external services such as domains, hosting, databases, and payments may incur additional charges.
Is it right for your project?
Use Cases
- Starting a B2B SaaS project that needs a separate database for each customer
- Quickly building a central admin backend with Filament to manage tenants and subscriptions
- SaaS products planning to use payment gateways such as Stripe to automatically provision tenants after payment
- Multi-tenant applications that need domain or subdomain entry points to distinguish tenants
Suitable For
- Developers familiar with Laravel and Filament who are preparing to build multi-tenant SaaS
- Teams that need a central admin panel to manage tenants, subscriptions, and billing in one place
- Individuals or companies that want to build on MIT-licensed code for secondary development
Getting started & customization
Use these recorded setup notes alongside the repository instructions for your chosen version.
- 1
Requires PHP 8.2+, Composer, Node.js, and NPM; MySQL 8.0+ or SQLite is recommended for the database, and Redis is required
- 2
After cloning the repository, run composer install and npm install in sequence, copy .env.example, and generate the application key
- 3
Configure the central database connection, run php artisan migrate --seed, then run npm run build
- 4
Run php artisan shield:generate --all to generate permissions, and use php artisan shield:super-admin to assign the super admin role
- 5
For local subdomains, Laravel Valet or Laravel Herd is recommended to handle *.test domains
License & source material
Usage conditions & limitations
Free to use · keep license noticeThis entry covers the free version in the public repository under the MIT license; the free scope is the code of this version and does not mean that external services or third-party assets are free.
Must comply with when using
- The code of this version may be used, modified, commercialized, and distributed for free.
- When distributing copies or substantial portions of the code, retain the original author's copyright notice and the full MIT license notice.
- The code is provided as is; warranties and limitations of liability are governed by the original license and applicable law.
Additional costs & items to verify
- Automatic tenant provisioning via Stripe payment is only a documentation example and is not included in the repository; you need to install Laravel Cashier, configure Stripe keys and webhooks, and write the controller and frontend purchase page yourself.
- Using the payment-based automatic provisioning feature requires your own Stripe account and API keys (STRIPE_KEY, STRIPE_SECRET, STRIPE_WEBHOOK_SECRET), which are external paid services.
- Running the project requires your own database (MySQL 8.0+ or SQLite recommended) and Redis; related hosting and operational costs are borne by the user.
- The author offers paid custom development services, which are optional commercial services and do not affect the use of the free MIT-licensed code.
- Demo images, fonts, icons, and other third-party assets must be checked against their respective licenses and cannot be judged solely by the code's MIT license.
- External services such as domains, hosting, databases, payments, or AI may incur additional charges.
View Original Text Basis
Permission is hereby granted, free of charge
Original License Text
A key feature of a SaaS application is automatically provisioning a new tenant account after a successful payment. Here’s a high-level guide on how to implement this using Stripe and Laravel Cashier.
Original README
Add your Stripe keys and a webhook secret to your `.env` file.
Original README
MySQL 8.0+ (Recommended) or SQLite
Original README
https://github.com/danihidayatx/tenancy-starterkit/blob/main/LICENSE.mdhttps://github.com/danihidayatx/tenancy-starterkit/blob/main/README.mdI offer custom development services to help you bring your project vision to life.
Original README
Compiled by DeepSeek based on repository license and README ·2026-10-03. Results only cover the materials read; dependencies, images, fonts, and subsequent term changes are subject to their respective original texts.
Project checks & description sources
Template Information
- Source platforms
- GitHub
- Documentation and maintenance reference score
- More documented · 88 / 100
- Technologies
- Laravel
- Website type
- SaaS · Starter
How this score is calculated
Our heuristic uses license records (up to 30), a demo link (12), a preview (10), stars (15), recorded maintenance (15), description completeness (8), feature records (5) and classification data (5). It is not a code, security or performance test, or a Google score. A link does not establish tested functionality.
What to verify for this project
- Repository update recorded
- 2026-02-13
- Screenshot last checked
- 2026-10-03
A demo link is listed. Check it with your own content and viewport sizes; its presence does not confirm that forms, authentication or payments work.
The catalog identifies Laravel as the primary stack. Check the actual dependency manifest and lockfile for versions and hosting requirements. These notes use recorded metadata, not a code audit or a deployment test.
Use a selection guide →How this description was prepared
AI-assisted description based on catalog records and repository material. Repository authors are not automatically the reviewers of this description.
Automatically checked against source and license rules; no manual editorial review.
Inspect the recorded source material
SHA-256: 373bd7b8cf197d792a38627697fe7e19e4668f14ea06f6e485f21b15b02af123
2026-10-03T03:25:49.035Z
Source file / repository# Laravel Tenancy Starter Kit
A robust, production-ready starter kit for building multi-tenant applications with [Laravel](https://laravel.com) and [stancl/tenancy](https://tenancyforlaravel.com). This boilerplate comes pre-configured with a powerful Central Admin Panel built on [Filament](https://filamentphp.com) to manage tenants, subscriptions, and billing.
**Built by and actively used at [quikpl.com](https://quikpl.com) to power our own SaaS platform.**
## Table of Contents
- [Features](#features)
- [Prerequisites](#prerequisites)
- [Installation](#installation)
- [Usage](#usage)
- [Automating Tenant Provisioning with Payments](#automating-tenant-provisioning-with-payments-stripe-example)
- [Testing](#testing)
- [Useful Documentation](#useful-documentation)
- [Architecture Overview](#architecture-overview)
- [Contributing](#contributing)
- [Custom Development Services](#custom-development-services)
- [License](#license)
## Features
### Multi-Tenancy (stancl/tenancy v3)
- **Database per Tenant:** Complete data isolation with automatic database creation and migration.
- **Domain Identification:** Tenants are identified by domains/subdomains.
- **Tenant Lifecycle Management:** Automated jobs for creating, migrating, and deleting tenant databases.
- **Tenant-Aware Services:** Filesystem, Cache, Queue, and Redis are configured to be tenant-aware.
### Central Administration (Filament v5)
- **Tenant Management:** Create, update, and delete tenants directly from the admin panel.
- **Subscription Billing:**
- **Plans Management:** Create and manage flexible subscription plans.
- **Subscription Tracking:** Monitor tenant subscriptions and statuses.
- **Invoicing:** Generate and manage invoices for tenants.
- **Role-Based Access Control:** integrated with Filament Shield (v3) for granular permissions.
### Modern Stack
- **Framework:** Laravel 12
- **Admin Panel:** Filament v5
- **Frontend:** Livewire v4 + Tailwind CSS v4
- **Testing:** Pest v4
- **Tooling:** Laravel Pint (Code Style), Laravel Sail (Docker)
## Prerequisites
- PHP 8.2+
- Composer
- Node.js & NPM
- MySQL 8.0+ (Recommended) or SQLite
- Redis
**Recommendation:** For local development, especially with subdomains, we highly recommend using [Laravel Valet](https://laravel.com/docs/valet) (macOS) or [Laravel Herd](https://herd.laravel.com/). These tools make handling `*.test` domains seamless.
## Installation
1. **Clone the repository**
```bash
git clone https://github.com/danihidayatx/tenancy-starterkit.git
cd tenancy-starterkit
```
2. **Install PHP dependencies**
```bash
composer install
```
3. **Install Node dependencies**
```bash
npm install
```
4. **Environment Configuration**
```bash
cp .env.example .env
php artisan key:generate
```
Update your `.env` file with your database credentials. Ensure you have a central database created.
```env
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=tenancy_central
DB_USERNAME=root
DB_PASSWORD=
```
5. **Run Migrations & Seeds**
This will migrate the central database and seed default roles/permissions.
```bash
php artisan migrate --seed
```
6. **Build Assets**
```bash
npm run build
```
7. **Generate Shield Permissions & Assign Super Admin**
First, generate all permissions for Filament Shield. When prompted, select `permissions` for what you'd like to manage.
```bash
php artisan shield:generate --all
```
Next, assign the `super_admin` role to a user. When prompted, choose the `admin` panel and then select the `UserID` of the super admin (usually `1`).
```bash
php artisan shield:super-admin
```
## Usage
### Local Development with Valet (Recommended)
If you are using Valet:
1. Park or link your directory: `valet link tenancy-starterkit`
2. Your app is now available at `http://tenancy-starterkit.test`.
### Accessing the Central Admin
Visit `http://tenancy-starterkit.test/admin` (or your configured domain) and log in with the admin user you created.
### Creating a Tenant
1. Navigate to the **Tenants** resource in the admin panel.
2. Click **New Tenant**.
3. Fill in the tenant details and assign a domain.
* *Tip: Use subdomains like `foo` to access `foo.tenancy-starterkit.test` automatically with Valet.*
4. The system will automatically:
- Create a new database for the tenant.
- Run tenant-specific migrations.
- Create the domain record.
### Accessing a Tenant
Once a tenant is created (e.g., with id `foo`), you can access their application at:
`http://foo.tenancy-starterkit.test`
## Automating Tenant Provisioning with Payments (Stripe Example)
A key feature of a SaaS application is automatically provisioning a new tenant account after a successful payment. Here’s a high-level guide on how to implement this using Stripe and Laravel Cashier.
The core idea is to create a Stripe webhook that, upon a successful payment, creates a `Tenant` model, which in turn triggers the automatic provisioning jobs.
1. **Install Laravel Cashier (Stripe)**
```bash
composer require laravel/cashier
php artisan cashier:install
php artisan migrate
```
2. **Configure Stripe**
Add your Stripe keys and a webhook secret to your `.env` file.
```env
STRIPE_KEY=pk_...
STRIPE_SECRET=sk_...
STRIPE_WEBHOOK_SECRET=whsec_...
```
3. **Create a Webhook Controller**
This controller will handle incoming events from Stripe.
```bash
php artisan make:controller StripeWebhookController
```
In your `StripeWebhookController.php`, create a method to handle the `checkout.session.completed` event. This is where the magic happens.
4. **Define the Webhook Route**
In `routes/web.php`, create a route that points to your new controller. Remember to exclude it from CSRF protection.
```php
Route::post(
'stripe/webhook',
[StripeWebhookController::class, 'handleWebhook']
)->name('cashier.webhook');
```
5. **Implement the Controller Logic**
Inside your `handleWebhook` method:
- Verify the webhook signature.
- Get the user and payment details from the Stripe session object.
- **Crucially, create the `Tenant` record.** You can pass user details or generate a unique ID.
```php
// Example logic in your controller
$session = $event->data['object'];
$user = User::find($session->client_reference_id);
$tenant = App\Models\Central\Tenant::create([
'id' => 'tenant-' . uniqid(),
'name' => $user->name . "'s Team",
'owner_id' => $user->id,
]);
$tenant->createDomain([
'domain' => strtolower(str_replace(' ', '', $user->name))
]);
```
6. **Automatic Provisioning**
That's it! The `TenancyServiceProvider` is already configured to listen for the `TenantCreated` event. Once the `Tenant` model is created in the webhook, the service provider will automatically trigger the job pipeline to:
- Create the tenant's database.
- Run the tenant's migrations.
- Perform any other setup jobs you've defined.
7. **Frontend Integration**
You will need to build a UI for users to select a plan and initiate the Stripe Checkout session. The `app/Filament/Pages/PurchasePlan.php` is a great starting point for this.
## Testing
This project uses **Pest** for testing and comes with a foundational test suite to ensure the core multi-tenancy and Filament features are working as expected. We highly recommend you extend this test suite as you build out your application.
### Running Tests
```bash
# Run all tests
php artisan test
# Run tests with a compact report
php artisan test --compact
# Run a specific test file (e.g., feature test)
php artisan test tests/Feature/Central/TenantLifecycleTest.php
# Run unit tests
php artisan test --group=unit
```
### Existing Test Structure
- **`tests/Feature/Central/`**: Contains feature tests for the central application, covering functionalities such as:
- `InvoiceTest.php`: Tests invoice-related features.
- `SubscriptionTest.php`: Tests subscription management.
- `TenantLifecycleTest.php`: Essential tests for tenant creation, migration, and deletion.
- `UserTest.php`: Tests user management and authentication.
- **`tests/Feature/Tenant/AppTest.php`**: A basic feature test for the tenant-specific application, ensuring it loads correctly. This is a good starting point for your tenant-specific feature tests.
- **`tests/Unit/ExampleTest.php`**: An example unit test.
### Extending Your Test Suite
- **Central Application Tests:** When adding new features to your central admin panel (e.g., new Filament resources, custom pages, or central API endpoints), create new feature tests in `tests/Feature/Central/`.
- **Tenant Application Tests:** For any features specific to the tenant application (e.g., tenant-specific models, controllers, or API endpoints), create feature tests in `tests/Feature/Tenant/`. Remember to leverage [Pest's multi-tenancy testing utilities](https://tenancyforlaravel.com/docs/v3/testing#testing-with-tenancy) when interacting with tenant contexts.
- **Unit Tests:** For isolated logic (e.g., service classes, complex helper functions, or model methods without database interaction), create unit tests in `tests/Unit/`.
## Useful Documentation
- **Laravel Tenancy (stancl/tenancy):** [https://tenancyforlaravel.com/docs/v3](https://tenancyforlaravel.com/docs/v3) - *The core multi-tenancy package.*
- **Filament PHP:** [https://filamentphp.com/docs](https://filamentphp.com/docs) - *The admin panel framework.*
- **Laravel Documentation:** [https://laravel.com/docs](https://laravel.com/docs) - *The PHP framework.*
- **Livewire:** [https://livewire.laravel.com/docs](https://livewire.laravel.com/docs) - *Dynamic frontend components.*
- **Tailwind CSS:** [https://tailwindcss.com/docs](https://tailwindcss.com/docs) - *Utility-first CSS framework.*
## Architecture Overview
### Central Context (`App\Models\Central`)
Models and logic related to the management of the SaaS platform itself.
- **User:** Administrators of the central application.
- **Tenant:** The entity representing a customer account.
- **Domain:** The domain(s) associated with a tenant.
- **Plan/Subscription/Invoice:** Billing-related models.
### Tenant Context (`App\Models\Tenant`)
Models and logic specific to the tenant's application.
- *Currently empty boilerplate.*
- Define your application's specific models here (e.g., `Product`, `Order`, `Post`).
- Migrations for these models go in `database/migrations/tenant`.
### Routing
- `routes/web.php`: Routes for the Central Application (Landing page, Admin Panel).
- `routes/tenant.php`: Routes for the Tenant Application (accessed via subdomain).
## Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
1. Fork the project
2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request
## Custom Development Services
Need custom features, additional integrations, or professional assistance in developing your multi-tenant application?
I offer custom development services to help you bring your project vision to life. Whether it's implementing new features, performance optimization, or technical support, feel free to contact me.
**Contact me to discuss your project needs!**
- **Email:** [email protected]
## License
This project is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).Explore similar templates
Compare previews and descriptions within the same stack and category.

sage
Sage is a WordPress starter theme maintained by Roots, using Laravel Blade components and templates, Vite builds, Tailwind CSS, and built-in block editor support.
Laravel · Starter

wave
Wave is an open-source SaaS starter kit built on Laravel and released under the MIT license.
Laravel · SaaS

filament-starter
A Laravel TALL stack starter template maintained by Log1x, with a preconfigured Filament admin panel and plugins including Curator, Gravatar, Exceptions, Jobs Monitor, Breezy, Peek, and Logger.
Laravel · Starter

electrik
Electrik is a Laravel SaaS starter kit installed as a Composer package, with authentication, teams, Stripe subscription billing, and the Slate 3 interface under the Electrik\ namespace rather than copied into App\.
Laravel · SaaS

php-saas
php-saas is a Laravel-based SaaS starter positioned as an everything-included kit. It generates new projects via a global Composer command and includes authentication with two-factor, API tokens, Stripe and Paddle billing, and project, team, and organization management.
Laravel · SaaS

filament-jetstream
A Laravel starter kit that implements Jetstream-like authentication and account features using Filament's native panels and components. It includes login, registration, two-factor authentication, session management, user profiles, and optional teams and API tokens.
Laravel · Starter
