gecche/laravel-multidomain
Run one Laravel codebase across multiple domains/tenants. Automatically load per-domain .env, storage paths, and database connections so each customer can have isolated config, data, and files while sharing the same application code.
client1.app.com) and later migrate to database-per-tenant or full isolation if needed.client1.agency.com).tenant1.app.com with its own DB/cache).franchise-ny.app.com)..env, storage, and DB per tenant).*.app.com configured in DNS).stancl/tenancy)./tenant1/).$_SERVER['SERVER_NAME'] is unreliable (requires custom domain detection)."This package lets us run multiple independent client sites—like a SaaS platform or agency—under one Laravel instance, cutting server costs by 70%+ while keeping each client’s data/config isolated. For example, client1.ourapp.com and client2.ourapp.com can share the same code but have their own databases, storage, and settings. It’s like having a ‘white-label’ factory for our software, with zero extra dev work. We avoid the complexity of custom multi-tenancy builds and can scale by adding domains in minutes via php artisan domain:add."
Key Benefits:
**"This is a battle-tested Laravel package that handles subdomain-based multi-tenancy with minimal boilerplate. Here’s how we’d use it:
Application class and override QueueServiceProvider (10-minute setup).php artisan domain:add client1.com—it auto-generates .env.client1.com, a storage/client1_com/ folder, and updates config..env and storage path at runtime. Queues, caches, and DBs are tenant-specific.--domain=client1.com (e.g., php artisan queue:work --domain=client1.com).Trade-offs:
client1.ourapp.com).ln -s for public storage per tenant (or use .htaccess for SPAs).Alternatives Considered:
stancl/tenancy: Overkill for subdomain-only needs.Recommendation: Use this for subdomain-based multi-tenancy where tenants share code but need isolated configs. For database-per-tenant, pair with stancl/tenancy later."**
How can I help you explore Laravel packages today?