PHPackages                             mostbyte/multidomain - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. mostbyte/multidomain

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

mostbyte/multidomain
====================

This is my package multidomain

v2.2.6(2mo ago)0409MITPHPPHP ^8.3CI failing

Since Jan 4Pushed 2mo ago2 watchersCompare

[ Source](https://github.com/mostbyte/multidomain)[ Packagist](https://packagist.org/packages/mostbyte/multidomain)[ Docs](https://github.com/mostbyte/multidomain)[ RSS](/packages/mostbyte-multidomain/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (10)Dependencies (18)Versions (19)Used By (0)

Laravel Multidomain – Multi-tenancy package for Laravel applications
====================================================================

[](#laravel-multidomain--multi-tenancy-package-for-laravel-applications)

[![Latest Version on Packagist](https://camo.githubusercontent.com/3828c3d2b51ed7297ff42b95194faebf7016f401dfb18ca187311a3beecca6d2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d6f7374627974652f6d756c7469646f6d61696e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mostbyte/multidomain)[![GitHub Tests Action Status](https://camo.githubusercontent.com/a84f54e08b39ff6bc274df2f4fc62af83f65eddad1e41c89f4e03e2a83bc58c7/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d6f7374627974652f6d756c7469646f6d61696e2f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/mostbyte/multidomain/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/a4affdd94cc4050f24e8e8e8569781115a368e0a9eac5c96a4a50af9711c376b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d6f7374627974652f6d756c7469646f6d61696e2f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/mostbyte/multidomain/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/8e1fa4349822afeb26a7bbcd6c7be0a92e36b49eff80928f28b25b1ede8fe72f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d6f7374627974652f6d756c7469646f6d61696e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mostbyte/multidomain)

This package provides full-featured multi-tenancy support for Laravel applications. It allows you to create and manage isolated database schemas or connections per tenant, simplifying the development of SaaS and modular systems.

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

[](#installation)

You can install the package via composer:

```
composer require mostbyte/multidomain
```

You can publish and run the migrations with:

```
php artisan vendor:publish --tag="multidomain-migrations"
php artisan migrate
```

You can publish the config file with:

```
php artisan vendor:publish --tag="multidomain-config"
```

This is the contents of the published config file:

```
return [
];
```

Optionally, you can publish the views using

```
php artisan vendor:publish --tag="multidomain-views"
```

Usage
-----

[](#usage)

```
use Mostbyte\Multidomain\Facades\Multidomain;

Multidomain::setTenant('tenant_1');
// Your tenant-specific logic here
```

### Example Workflow

[](#example-workflow)

1. Create a new schema for a tenant: ```
    php artisan schema:migrate schema
    ```
2. Run migrations for that tenant: ```
    php artisan schema:migrate migrate
    ```
3. All tenant-specific models and queries will automatically be scoped to the active schema.

Creating a schema is idempotent: running `mostbyte:schema` for a tenant whose schema already exists reports "Schema already exists, nothing to do." and exits with code `0`, so re-running provisioning is safe.

### API authentication

[](#api-authentication)

The package routes (`POST /{domain}/multidomain/{type}`) create, migrate and drop tenant schemas, so they are protected by a shared secret. Every request must carry it in the `X-API-KEY` header:

```
curl -X POST https://example.com/tenant-1/multidomain/schema \
  -H "X-API-KEY: ${MULTIDOMAIN_API_KEY}"
```

Set the secret in the consuming application's `.env`:

```
MULTIDOMAIN_API_KEY=your-shared-secret
```

The check runs before any database access and behaves as follows:

SituationResponse`MULTIDOMAIN_API_KEY` empty or unset`403` – fail closed, the routes stay unusable`X-API-KEY` header missing`401``X-API-KEY` does not match`403``X-API-KEY` matchesrequest proceedsAn unconfigured key rejects every request on purpose: leaving the schema drop endpoint open is worse than breaking provisioning. Successful requests keep the existing response shape (`200` with `{success, status, message}`).

`VerifyApiKeyMiddleware::class` is listed first in the default `config('multidomain.middleware')`, but the routes prepend it regardless of what that config contains. Overriding the middleware list in a published `config/multidomain.php` — for example one copied from an older version of this package — cannot disable the api key check or move it behind the tenant resolution logic. It is never applied twice if you also list it yourself.

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

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

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Mostbyte Team](https://github.com/mostbyte)
- [Jasur Dustmurodov](https://github.com/dorsone)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

46

—

FairBetter than 92% of packages

Maintenance85

Actively maintained with recent releases

Popularity13

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 70.9% 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 ~29 days

Recently: every ~0 days

Total

18

Last Release

77d ago

Major Versions

1.1.1 → 2.0.02025-11-12

PHP version history (2 changes)1.0.0PHP ^8.2

2.0.0PHP ^8.3

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/59536101?v=4)[Firdavs](/maintainers/firdavsibodullaev)[@firdavsibodullaev](https://github.com/firdavsibodullaev)

---

Top Contributors

[![Dorsone](https://avatars.githubusercontent.com/u/84617193?v=4)](https://github.com/Dorsone "Dorsone (39 commits)")[![firdavsibodullaev](https://avatars.githubusercontent.com/u/59536101?v=4)](https://github.com/firdavsibodullaev "firdavsibodullaev (10 commits)")[![azizbekvahidov](https://avatars.githubusercontent.com/u/4863547?v=4)](https://github.com/azizbekvahidov "azizbekvahidov (6 commits)")

---

Tags

laravelmultidomainMostbyte

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/mostbyte-multidomain/health.svg)

```
[![Health](https://phpackages.com/badges/mostbyte-multidomain/health.svg)](https://phpackages.com/packages/mostbyte-multidomain)
```

###  Alternatives

[codewithdennis/filament-select-tree

The multi-level select field enables you to make single selections from a predefined list of options that are organized into multiple levels or depths.

329575.9k33](/packages/codewithdennis-filament-select-tree)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3914.8k](/packages/rawilk-profile-filament-plugin)[tarfin-labs/event-machine

Event-driven state machines for Laravel with event sourcing, type-safe context, and full audit trail.

209.6k](/packages/tarfin-labs-event-machine)[tapp/filament-form-builder

User facing form builder using Filament components

133.5k5](/packages/tapp-filament-form-builder)

PHPackages © 2026

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