PHPackages                             sanicode/elastik-tenancy - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. sanicode/elastik-tenancy

ActiveProject[Framework](/categories/framework)

sanicode/elastik-tenancy
========================

The starterkit application, based on Laravel Jetstream for support multi-tenancy platform.

v1.2.0(1y ago)5182[1 issues](https://github.com/sanicode/elastik-tenancy/issues)MITBladePHP ^8.2

Since Aug 9Pushed 1y ago1 watchersCompare

[ Source](https://github.com/sanicode/elastik-tenancy)[ Packagist](https://packagist.org/packages/sanicode/elastik-tenancy)[ RSS](/packages/sanicode-elastik-tenancy/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (13)Versions (4)Used By (0)

[![Laravel Logo](https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg)](https://laravel.com)[![Jetstream Logo](https://camo.githubusercontent.com/668b2a79d0fd2846c47974e5819cc20121b12148d327dbc50c91be48ee7bdab1/68747470733a2f2f706963706572662e696f2f68747470733a2f2f6c61726176656c6e6577732e73332e616d617a6f6e6177732e636f6d2f696d616765732f6a657473747265616d2e706e67)](https://jetstream.laravel.com)

[![Build Status](https://github.com/laravel/framework/workflows/tests/badge.svg)](https://github.com/laravel/framework/actions)[![Total Downloads](https://camo.githubusercontent.com/b0a7ee2f3f0208712ecb1081b9d6fcf05045c10cd6f345abcb924f5512c0d346/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c61726176656c2f6672616d65776f726b)](https://packagist.org/packages/laravel/framework)[![Latest Stable Version](https://camo.githubusercontent.com/9e6071b5dd1a4a3bcabe3cca9d97a447d030caeb940f2adbd18699bc0b326702/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c61726176656c2f6672616d65776f726b)](https://packagist.org/packages/laravel/framework)[![License](https://camo.githubusercontent.com/4a64c31c71966d152c876eea1f35e85fbd33d57ddf5754260a41f053aa72c5b2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6c61726176656c2f6672616d65776f726b)](https://packagist.org/packages/laravel/framework)

About Elastik Tenancy
---------------------

[](#about-elastik-tenancy)

**Laravel Jetstream** is a robust application scaffolding for Laravel, providing essential features such as user authentication, registration, email verification, two-factor authentication, session management, API support via Laravel Sanctum, and optional team management. **Elastik Tenancy** combined with a TenancyForLaravel (a package by Stancl that provides multi-tenancy support for Laravel applications), allows you to build a powerful, multi-tenant SaaS application with user authentication, team management, and other features provided by Jetstream, all while keeping tenant data and configuration isolated.

Overview
--------

[](#overview)

- **Laravel Jetstream**: Provides scaffolding for essential features like user authentication, registration, email verification, two-factor authentication, session management, and team management.
- **TenancyForLaravel**: A flexible multi-tenancy package that supports tenant identification, database separation, and tenant-specific configurations.

Benefits of Combining Jetstream and TenancyForLaravel:
------------------------------------------------------

[](#benefits-of-combining-jetstream-and-tenancyforlaravel)

**Scalability**: The combined setup allows you to scale your application to support multiple tenants efficiently. Feature-Rich: You get the best of both worlds—Jetstream's user management features and TenancyForLaravel’s robust multi-tenancy support.

**Flexibility**: The architecture can be adapted to various use cases, from small SaaS applications to large enterprise solutions.

Integrating Multitenancy with Laravel Jetstream
-----------------------------------------------

[](#integrating-multitenancy-with-laravel-jetstream)

### Tenant Identification:

[](#tenant-identification)

- **Subdomains**: Each tenant can be identified by a unique subdomain (**e.g., tenant1.yourapp.com**). Middleware can be used to detect the subdomain and load the appropriate tenant configuration.
- **Domains**: Each tenant can have its domain (**e.g., tenant1.com**), with the application routing requests to the correct tenant based on the domain.
- **Query String or Path**: Tenants can be identified by a unique identifier in the URL path or query string (**e.g., yourapp.com/tenant1**).

### User Authentication:

[](#user-authentication)

- Jetstream’s user authentication system can be extended to support multitenancy by associating users with a specific tenant. For example, each user could have a **tenant\_id** field in the database, linking them to the appropriate tenant.
- Authentication logic can be adjusted to ensure that users can only log in to their respective tenants.

### Database Separation:

[](#database-separation)

- Depending on your multitenancy approach, you might use a shared database with a **tenant\_id** column to segregate data or multiple databases where each tenant has its own database.
- Laravel's database connections can be dynamically configured based on the tenant, ensuring that the correct database is used for each request.

### Middleware:

[](#middleware)

- Custom middleware can be used to identify the current tenant and configure the application accordingly. This includes setting the database connection, loading tenant-specific configurations, and ensuring that authenticated users belong to the correct tenant.

### Routes and Controllers:

[](#routes-and-controllers)

- Routes can be grouped based on tenants, allowing for tenant-specific functionality within your application. Controllers can be adapted to ensure they handle data in the context of the current tenant.

Elastik Tenancy Features
------------------------

[](#elastik-tenancy-features)

- **Laravel Jetstream**: Provides authentication, registration, email verification, two-factor authentication, session management, API support, and optional team management, etc.
- **Multi-Tenancy**: Supports tenant identification via subdomains, domains, or path-based routing.
- **Tenant Data Isolation**: Ensures that each tenant's data is securely separated, using either a shared database with tenant-specific identifiers or multiple databases.
- **Dynamic Tenant Configuration**: Automatically configures the application based on the current tenant's environment.
- **Scalability**: Built to handle multiple tenants efficiently while maintaining performance.

Installation
------------

[](#installation)

To get started with this project, follow these steps:

### 1. Clone the Repository

[](#1-clone-the-repository)

```
git clone git@github.com:sanicode/elastik-tenancy.git
cd elastik-tenancy
```

### 2. Alternative Install with Composer

[](#2-alternative-install-with-composer)

```
composer create-project sanicode/elastik-tenancy
cd elastik-tenancy
```

### 3. Install Dependencies

[](#3-install-dependencies)

```
composer update
```

### 4. Next, be sure to compile your assets

[](#4-next-be-sure-to-compile-your-assets)

```
npm install && npm run build
```

### 5. Set Up Environtment Variables

[](#5-set-up-environtment-variables)

Copy the .env.example file to .env and configure the necessary environment variables, including your database connection and tenant identification method.

```
cp .env.example .env
```

### 6. Generate Application Key

[](#6-generate-application-key)

```
php artisan key:generate
```

Important

If you used the Laravel installer and chose `sqlite` as your database, the migrations may have already been run. In which case, you're good to go 🎉 Otherwords you'll need to connect a db and run this command 👇

### 7. Run database migrations

[](#7-run-database-migrations)

```
php artisan migrate

```

### 8. Configure Tenants

[](#8-configure-tenants)

If you're using subdomains or multiple databases, ensure that your server is configured correctly to handle tenant routing. This might involve setting up wildcard subdomains or configuring additional databases.

### 9. Serve the Application

[](#9-serve-the-application)

```
php artisan serve
```

### 10. Open your first page in browser

[](#10-open-your-first-page-in-browser)

[![Screenshot 2024-08-10 at 12 33 56](https://private-user-images.githubusercontent.com/6724789/356791126-185ddc13-93fa-45b1-97e4-d1d20f54fe5e.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzUyMDAyOTMsIm5iZiI6MTc3NTE5OTk5MywicGF0aCI6Ii82NzI0Nzg5LzM1Njc5MTEyNi0xODVkZGMxMy05M2ZhLTQ1YjEtOTdlNC1kMWQyMGY1NGZlNWUucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI2MDQwMyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNjA0MDNUMDcwNjMzWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MzU4ZTI4NTM5YjgxMzNmODQxNWQ2YjVjNDdkNTFiNzYxYzc5NTZjOTFiZThjYjgxYzM2Y2Y5YWE5ZTg4ZGQ1OSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.A6jWRKeirE07tvEJxL2AFTmf8GFjLzLxv1aMF8XdZCc)](https://private-user-images.githubusercontent.com/6724789/356792912-4c74d64b-4cc1-4502-8aaf-540258678f04.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjMyNzA5ODIsIm5iZiI6MTcyMzI3MDY4MiwicGF0aCI6Ii82NzI0Nzg5LzM1Njc5MjkxMi00Yzc0ZDY0Yi00Y2MxLTQ1MDItOGFhZi01NDAyNTg2NzhmMDQucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDgxMCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA4MTBUMDYxODAyWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9Yzk1YmNjNGUwYTkxMGJkNzA2ZTJiNWE4YmRiMDYxMDhiMzgzMDY2YmFkZjJmY2YxMWRiZTlkMDU5NGUyNTRmYiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.ZWFyt0ZxH6ET30Ef9UgzNk_c_sDSJSeRHXdKWIwrXew)

Usage
-----

[](#usage)

After setting up the project, you can register new tenant with Domain/Subdomain field in register form and log in as a user. Each user domain/subdomain will be associated with a specific tenant, and all operations will be tenant-scoped. For the basic usage you can input subdomain name without dot\[.\] added for suffix, for the example : tenant1, tenant2, etc.

[![register-page](https://private-user-images.githubusercontent.com/6724789/356790844-8e90e621-a986-4bc9-bcdd-7c282f3c49e5.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzUyMDAyOTMsIm5iZiI6MTc3NTE5OTk5MywicGF0aCI6Ii82NzI0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MjM5MzA4ZmY3NTg0YzNmNDNiY2FiNmFjZTk5MjU0YjljYzgzMmNmZGNlYzk2YmY1ZiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.3OroRI8tEF1Krq_tl8Yk-FL3wzjxoI5je6t2ay3Irp8)

Example Routes:
---------------

[](#example-routes)

- **** - Dashboard for Tenant 1
- **** - Dashboard for Tenant 2

Visit your application homepage and you should be good to go 🤘

Contributing
------------

[](#contributing)

Contributions are welcome! Please feel free to submit a Pull Request or open an Issue.

License
-------

[](#license)

The Elastik Tenancy is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).

Acknowledgements
----------------

[](#acknowledgements)

- [Laravel](https://laravel.com/)
- [Laravel Jetstream](https://jetstream.laravel.com/)
- [Tenancy for Laravel](https://tenancyforlaravel.com/)

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance30

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Total

3

Last Release

644d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7600d0fc3cd1d35d967badbaff54e2a69e327c53e720012a3ccefb12db67a509?d=identicon)[sani](/maintainers/sani)

---

Top Contributors

[![sanicode](https://avatars.githubusercontent.com/u/6724789?v=4)](https://github.com/sanicode "sanicode (3 commits)")

---

Tags

frameworklaravelsaasmultitenancyjetstream

###  Code Quality

TestsPHPUnit

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/sanicode-elastik-tenancy/health.svg)

```
[![Health](https://phpackages.com/badges/sanicode-elastik-tenancy/health.svg)](https://phpackages.com/packages/sanicode-elastik-tenancy)
```

###  Alternatives

[bagisto/bagisto

Bagisto Laravel E-Commerce

26.2k161.6k7](/packages/bagisto-bagisto)[unopim/unopim

UnoPim Laravel PIM

9.4k1.8k](/packages/unopim-unopim)[raugadh/fila-starter

Laravel Filament Starter.

614.9k](/packages/raugadh-fila-starter)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
