gecche/laravel-multidomain
Run one Laravel codebase across multiple domains/tenants. Load domain-specific .env, storage path and database/config per customer, enabling clean multi-domain deployments without duplicating the app.
Application, QueueServiceProvider), ensuring compatibility with Laravel’s ecosystem (e.g., Horizon, queues, caching)..env files and domain-specific configs, aligning with Laravel’s convention-over-configuration philosophy.storage:link management for per-domain public storage (a known gap).bootstrap/app.php and config/app.php modifications).13.* for Laravel 13).HorizonServiceProvider override.QUEUE_DEFAULT per domain).| Risk Area | Severity | Mitigation Strategy |
|---|---|---|
| Bootstrap Override | High | Test in staging; document rollback steps. |
| Queue Isolation | Medium | Validate queue configurations per domain. |
| Storage Paths | Medium | Automate storage:link scripts for CI/CD. |
| Domain Detection | Medium | Customize domain_detection_function_web if $_SERVER['SERVER_NAME'] is unreliable. |
| Config Merging | Low | Test config:cache --domain for conflicts. |
domain:add/domain:remove?)config:cache --domain) impact startup time?Sentry tags, Laravel Debugbar customization?).env or config breaks the app? (e.g., fallback to default .env?)database, redis, beanstalkd (requires manual queue separation).config:cache --domain for per-domain cached configs.storage:link management needed for public storage..env for domain-specific variables (e.g., DB_DATABASE, APP_URL).QUEUE_CONNECTION per domain).bootstrap/app.php and config/app.php as per docs.php artisan vendor:publish --provider="Gecche\Multidomain\MultidomainServiceProvider".php artisan domain:list.config:cache --domain for each tenant.php artisan queue:work --domain=tenant1.com.domain:add).| Component | Compatibility Notes |
|---|---|
| Laravel | 10.x–13.x (use matching package version). |
| Horizon | Requires manual HorizonServiceProvider override. |
| Queues | Database/sync drivers need explicit queue separation. |
| Storage | Manual storage:link or custom scripts for per-domain public storage. |
| Middleware | Tenant context must be passed manually (e.g., app('domain')). |
| Testing | Use --domain flag in phpunit or pest tests. |
domain:add)..env files and config/domains/.domain:add/remove/update_env simplify tenant management.app.name)..env variables per domain in a shared wiki..env files.$_SERVER variables in custom environments.storage/ has correct ownership (e.g., www-data).app('domain') in Tinker to verify current domain.config/domains.php for registered domains.Sentry or Monolog tags.config:cache --domain in production to reduce I/O.SERVER_NAME is correctly forwarded (e.g., via X-Forwarded-Host).| Failure Scenario | Impact | Mitigation |
|---|---|---|
Corrupt .env file |
App crashes for a domain | Fallback to default .env or alert. |
| Storage path missing | Uploads fail | Automate storage:link in deploy. |
| Queue worker crashes | Jobs pile up for a domain | Supervisor restarts + monitoring. |
| Config merge conflicts | Overwritten settings | Validate configs in CI. |
| Domain detection failure | Wrong env loaded | Custom detection function. |
php artisan domain:add tenant.example.com..env.tenant_example_com and config/domains/tenant_example_com.php.php artisan config:cache --domain=tenant.example.com.--domain).app('domain')).tenant_id (e.g., Sentry tags).How can I help you explore Laravel packages today?