hyn / multi-tenant
Run multiple websites using the same laravel installation while keeping tenant specific data separated for fully independant multi-domain setups.
Fund package maintenance!
tenancy] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g.
[user1
user2
Open Collective
Requires
- php: ^8.0
- doctrine/dbal: ~2.5|~3.0
- laravel/framework: ^9.0|^10.0
- ramsey/uuid: ^4.0
Requires (Dev)
- fakerphp/faker: ^1.12
- laravel/laravel: ^9.0|^10.0
- mockery/mockery: ^1.0
- phpunit/phpunit: ^9.0
- symfony/dom-crawler: ~3.1
- 5.x-dev
- 5.9.1
- 5.9.0
- 5.8.2
- 5.8.1
- 5.8.0
- 5.7.3
- 5.7.2
- 5.7.1
- 5.7.0
- 5.6.4
- 5.6.3
- 5.6.2
- 5.6.1
- 5.6.0
- 5.5.0
- 5.4.5
- 5.4.4
- 5.4.3
- 5.4.2
- 5.4.1
- 5.4.0
- 5.4.0-beta.2
- 5.4.0-beta
- 5.3.1
- 5.3.0
- 5.2.7
- 5.2.6
- 5.2.5
- 5.2.4
- 5.2.3
- 5.2.2
- 5.2.1
- 5.2.0
- 5.2.0-beta
- 5.1.x-dev
- 5.1.17
- 5.1.16
- 5.1.15
- 5.1.14
- 5.1.13
- 5.1.12
- 5.1.11
- 5.1.10
- 5.1.9
- 5.1.8
- 5.1.7
- 5.1.6
- 5.1.5
- 5.1.4
- 5.1.3
- 5.1.2
- 5.1.1
- 5.1.0
- 5.1.0-beta.2
- 5.1.0-beta
- 5.0.x-dev
- 5.0.17
- 5.0.16
- 5.0.15
- 5.0.14
- 5.0.13
- 5.0.12
- 5.0.11
- 5.0.10
- 5.0.9
- 5.0.8
- 5.0.6
- 5.0.5
- 5.0.4
- 5.0.3
- 5.0.2
- 5.0.1
- 5.0.0
- 5.0.0-beta.8
- 5.0.0-beta.7
- 5.0.0-beta.6
- 4.x-dev
- 3.x-dev
- 2.x-dev
- 2.0.1
- 2.0.0
- 2.0.0-beta.4
- 2.0.0-beta.3
- 2.0.0-beta.2
- 2.0.0-beta.1
- 1.x-dev
- 1.0.1
- 1.0.1-beta.2
- 1.0.1-beta
- 1.0.0
- 0.9.2
- 0.9.1
- 0.9.0
- 0.8.1
- 0.8.0
- 0.7.5
- 0.7.4
- 0.7.3
- 0.7.1
- 0.7.0
- 0.6.4
- 0.6.3
- 0.6.2
- 0.6.1
- 0.6.0
- 0.5.7
- 0.5.5
- 0.5.4
- 0.5.3
- 0.5.2
- 0.5.1
- 0.5.0
- 0.4.4
- 0.4.3
- 0.4.2
- 0.4.1
- 0.4.0
- 0.3.1
- 0.3.0
- 0.2.9
- 0.2.8
- 0.2.7
- 0.2.6
- 0.2.5
- 0.2.4
- 0.2.3
- 0.2.2
- 0.2.1
- 0.2.0
- 0.1.5
- 0.1.4
- 0.1.3
- 0.1.2
- 0.1.1
- 0.1.0
- dev-bk/fix-migration-command-mutators
- dev-bk/release-5.7.1
- dev-bk/laravel-8-support
- dev-bk/support-soft-deletes
- dev-aa/test-vapor
- dev-aa/fix-apt-setup
- dev-aa/check-tenant-override
- dev-aa/fix-queue-provider
- dev-aa/753-investigate-psql-schema
- dev-dk/5.4-statements
- dev-bk/readme.md-fix
- dev-dk/dras
- dev-resolver-verification-test
This package is auto-updated.
Last update: 2024-10-18 20:33:14 UTC
README
The unobtrusive Laravel package that makes your app multi tenant. Serving multiple websites, each with one or more hostnames from the same codebase. But with clear separation of assets, database and the ability to override logic per tenant.
Suitable for marketing companies that like to re-use functionality for different clients or start-ups building the next software as a service.
Offers:
- Integration with the awesome Laravel framework.
- Event driven, extensible architecture.
- Close - optional - integration into the web server.
- The ability to add tenant specific configs, code, routes etc.
Database separation methods:
- One system database and separated tenant databases (default).
- Table prefixed in the system database.
- Or .. manually, the way you want, by listening to an event.
Complete documentation covers more than just the installation and configuration.
Requirements, recommended environment
- Laravel 9.0+.
- PHP 8.0+
- Apache or Nginx.
- MySQL, MariaDB, or PostgreSQL.
Please read the full requirements in the documentation.
Installation
composer require hyn/multi-tenant
Automatic service registration
Using auto discovery, the tenancy package will be auto detected by Laravel automatically.
Manual service registration
In case you want to disable webserver integration or prefer manual integration,
set the dont-discover
in your application composer.json, like so:
{ "extra": { "laravel": { "dont-discover": [ "hyn/multi-tenant" ] } } }
If you disable auto discovery you are able to configure the providers by yourself.
Register the service provider in your config/app.php
:
'providers' => [ // [..] // Hyn multi tenancy. Hyn\Tenancy\Providers\TenancyProvider::class, // Hyn multi tenancy webserver integration. Hyn\Tenancy\Providers\WebserverProvider::class, ],
Deploy configuration
First publish the configuration and migration files so you can modify it to your needs:
php artisan vendor:publish --tag tenancy
Open the config/tenancy.php
and config/webserver.php
file and modify to your needs.
Make sure your system connection has been configured in
database.php
. In case you didn't override the system connection name thedefault
connection is used.
Now run:
php artisan migrate --database=system
This will run the required system database migrations.
Backers
Thank you to all our backers! 🙏 [Become a backer]
Sponsors
Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]
Contributors
License and contributing
This package is offered under the MIT license. In case you're interested at contributing, make sure to read the contributing guidelines.
Testing
Run tests using:
vendor/bin/phpunit
If using MySQL, use:
LIMIT_UUID_LENGTH_32=1 vendor/bin/phpunit
Please be warned running tests will reset your current application completely, dropping tenant and system databases and removing the tenancy.json file inside the Laravel directory.
Changes
All changes are covered in the changelog.
Contact
Get in touch personally using;
- The email address provided in the composer.json.
- Discord chat.
- Twitter.