kjos/orchestra

Orchestra tool for Laravel and other

1.0.0 2025-07-12 04:19 UTC

README

Tests Packagist Version PHP License

🌐 Multilangue | Multilingual

πŸ‡¬πŸ‡§ English

kjos orchestra

A powerful multi-tenancy manager for Laravel, with built-in support for domain isolation, database separation, and automated Apache virtual host configuration.

Installation

composer require kjos/orchestra

Master tenant installation

Before beginning you must install the master tanant. We will ask you to configure the User wo will use for virtuals hosts creation. When User is configure, a shedule task is creating in your crontab table, you can type crontab -e to see it. The shedule task will use your User with it privileges to automate the creation et configuration of your virtualhost. virtualhosts are configured in /etc/apache2/sites-available directory.

Concept

kjos/orchestra simplifies the management of multi-tenant applications by providing:

  • Independent databases per tenant

  • Separate route files, config, and storage per tenant

  • Automatic setup of Apache virtual hosts

  • Easy tenant lifecycle management via Artisan commands

It’s ideal for SaaS platforms or systems requiring strict tenant isolation.

Getting Started

Master Tenant Setup

Before adding tenants, you must install and configure the master tenant.

What happens during setup?

You’ll configure a system User that will be used to manage Apache virtual hosts.

A scheduled task will be added to your crontab to automate virtual host creation.

Apache virtual hosts are stored in: /etc/apache2/sites-available/

Installation Steps

  1. Create & configure the master tenant

  2. Publish the config file:

php artisan vendor:publish --tag=orchestra-config
  1. Create the database for the master tenant

  2. Add the tenant to the .tenants file at your project root

  3. Create the site/ directory, which will contain subfolders for each tenant

  4. Link each tenant's /public directory to your Laravel public root

  5. Configure the virtual host:

  • Symlink: /var/www/html/{tenant-domain} β†’ project/site/{tenant-name}

  • Apache config: /etc/apache2/sites-available/{tenant-domain}.conf

  • Log file: /var/log/apache2/{tenant-domain}.log

  1. Enable the virtual host:
sudo a2ensite {tenant-domain}.conf
sudo systemctl reload apache2
  1. Register the service provider in config/app.php:
App\Providers\TenantServiceProvider::class,

The TenantServiceProvider is the central kernel that initializes and resolves tenant-specific context and configuration.

Artisan Commands

Install Master Tenant

php artisan orchestra:install the_master_tenant_name --domain=master_tenant_domain --driver=[mysql|pgsql]

❌ Uninstall Master Tenant

php artisan orchestra:uninstall the_master_tenant_name --driver=[mysql|pgsql]

βž• Create a New Tenant

php artisan orchestra:create the_tenant_name --domain=the_tenant_domain --driver=[mysql|pgsql] --migrate

βž– Delete a Tenant

php artisan orchestra:delete the_tenant_name --driver=[mysql|pgsql]

🧾 Available Options

Option Description
--domain The domain of the tenant
--driver Database driver pgsql or mysql
--migrate Either migrate the fresh tenant database or not

Additional Features

Each tenant has its own:

  • routes (API, web, console)

  • database

  • storage & cache

  • config context

Crontab automation for managing virtual hosts

Support for Laravel testing with tenant isolation

Dynamic tenant discovery via .tenants file

.

πŸ“ Directory Structure

project-root/
β”œβ”€β”€ site/
β”‚   β”œβ”€β”€ master/
β”‚   β”‚   └── routes/
β”‚   └── tenant-a/
β”‚   |   └── routes/
|   |__ tenant-b/
|       |__routes/
|
β”œβ”€β”€ .tenants
β”œβ”€β”€ config/orchestra.php
β”œβ”€β”€ app/Providers/TenantServiceProvider.php

πŸ‘€ Author

Maintained by Jean Koffi

πŸ“„ License

MIT Β© kjos/orchestra

🀝 Call for contributions

This project is open to contributions! Are you a developer, passionate about Laravel, or interested in multi-tenant architecture?

  • Fork the project

  • Create a branch (koor/my-feature)

  • Make a PR πŸ§ͺ

There are many other command for additionally configuration.