dazza-dev / hyn-multi-tenant
Maintained continuation of hyn/multi-tenant with Laravel 11 support. Run multiple websites on a single Laravel installation while keeping each tenant's data separated.
Requires
- php: ^8.2
- laravel/framework: ^12.0|^13.0
- ramsey/uuid: ^4.0
Requires (Dev)
- fakerphp/faker: ^1.23
- laravel/pint: ^1.30
- mockery/mockery: ^1.6
- orchestra/testbench: ^10.0|^11.0
- phpunit/phpunit: ^10.5|^11.0|^12.0
Conflicts
This package is auto-updated.
Last update: 2026-08-30 01:15:28 UTC
README
Run multiple websites from a single Laravel installation, each with one or more hostnames, keeping their data, assets and behaviour separated.
Which version do you need?
| Your Laravel version | What to use |
|---|---|
| 12 and 13 | dazza-dev/hyn-multi-tenant — this package |
| 11 | The 1.x line, in maintenance: security and isolation fixes only |
| 9 and 10 | The 0.x line, which continues hyn/multi-tenant 5.9 |
Every line is on Packagist under the same name:
composer require dazza-dev/hyn-multi-tenant:^2.0 # Laravel 12 and 13 composer require dazza-dev/hyn-multi-tenant:^1.0 # Laravel 11 composer require dazza-dev/hyn-multi-tenant:^0.10 # Laravel 9 and 10
About this repository
A maintained fork of hyn/multi-tenant by Daniël Klabbers. The design and practically all of the code are his and the original contributors'.
The original has received no commits since August 2023 and does not support
Laravel 11. Rather than migrate away, we picked up its maintenance. This is the
same code, the same Hyn\Tenancy\ namespace and the same API.
If the original project becomes active again we will gladly contribute these changes back.
Features
- Event driven, extensible architecture.
- Optional integration with nginx and apache.
- Tenant specific configuration, routes, views, translations and assets.
Tenant separation modes:
- A separate database per tenant, with its own user and credentials (default).
- A table prefix within the system database.
- Separate PostgreSQL schemas.
- Or your own, by listening to an event.
Requirements
- Laravel 12 or 13
- PHP 8.2 or newer. Laravel 13 itself asks for 8.3, so on 8.2 you get Laravel 12
- MySQL, MariaDB or PostgreSQL
Installation
composer require dazza-dev/hyn-multi-tenant
Coming from hyn/multi-tenant, read UPGRADE.md first. The
namespace does not change.
The service providers are registered through package auto discovery. To opt out
and register them yourself, add dazza-dev/hyn-multi-tenant to
extra.laravel.dont-discover and register:
Hyn\Tenancy\Providers\TenancyProvider::class, Hyn\Tenancy\Providers\WebserverProvider::class,
Configuration
php artisan vendor:publish --tag tenancy php artisan migrate --database=system
Adjust config/tenancy.php and config/webserver.php to taste. Make sure the
system connection is configured in database.php; the default connection is
used unless you override the system connection name.
Documentation
The original documentation applies to everything not listed as changed in UPGRADE.md.
Contributing, and what the test suite needs: CONTRIBUTING.md.
Testing
The suite creates and drops real databases and database users, so it needs a disposable environment. One matching CI is included:
docker compose run --rm php composer install docker compose run --rm php vendor/bin/phpunit
Target another engine or separation mode:
docker compose run --rm \
-e DB_CONNECTION=pgsql -e DB_HOST=pgsql \
-e TENANCY_SYSTEM_CONNECTION_NAME=pgsql \
php vendor/bin/phpunit
docker compose run --rm \
-e DB_HOST=mariadb -e TENANCY_DATABASE_DIVISION_MODE=prefix \
php vendor/bin/phpunit
Build against another PHP version with PHP_VERSION=8.4 docker compose build php.
The suite runs on 8.2, 8.3 and 8.4.
Running the suite drops tenant and system databases. Never point it at anything you care about.
Credits
- Daniël Klabbers — author of the original package.
- Contributors to the original project.
- Andres Daza — maintainer of this continuation.
To support the original author's work, the original project has an Open Collective.
License
MIT. Original copyright by Daniël Klabbers — see license.md.