This repository contains a Laravel application that leverages multi-tenancy capabilities to manage multiple organizations or tenants within a single application. The project uses a Laravel tenancy package to handle tenant isolation and resource segregation.
- Multi-Tenancy Support: Isolate data and resources for each tenant.
- Automatic Tenant Resolution: Identify tenants based on subdomains, domains, or other identifiers.
- Tenant-Specific Middleware: Apply tenant-specific logic at the request level.
- Central and Tenant Databases: Support for shared and isolated databases for tenants.
- Custom Scopes: Automatically scope queries to tenants.
- Easy Tenant Management: Tools to create, update, and delete tenants efficiently.
Ensure you have the following installed:
- PHP >= 8.3
- Composer
- MySQL or other compatible databases
- Laravel >= 12
-
Clone the repository:
git clone https://github.com/arfin-foysal/tenancy.git cd tenancy -
Install dependencies:
composer install
-
Set up the environment variables:
cp .env.example .env
Configure your
.envfile with database credentials and tenancy settings. -
Run migrations:
php artisan migrate
-
Seed the database (optional):
php artisan db:seed
-
Serve the application:
php artisan serve
-
Tenant Creation: Use the following command to create a new tenant:
php artisan tenant:create {tenant-name} -
Access Tenant: Access the tenant's application by navigating to their subdomain or domain (e.g.,
tenant1.example.com). -
Central Application: Manage tenants and global settings via the central domain (e.g.,
example.com).
-
Tenant Identification: Modify the configuration file
config/tenancy.phpto set the tenant resolver logic (e.g., subdomain, domain). -
Middleware: Use the provided tenant middleware to scope requests to the current tenant.
- Fork the repository.
- Create a feature branch:
git checkout -b feature-name
- Commit your changes:
git commit -m "Description of changes" - Push to the branch:
git push origin feature-name
- Open a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
For issues or feature requests, please create an issue in the repository.
Enjoy using the Laravel Tenancy Application!