gecche/laravel-multidomain
Run one Laravel codebase across multiple domains/tenants. Automatically load a domain-specific .env, storage path, and database/config per customer, enabling isolated data and settings while sharing the same application and deployment.
Application, QueueServiceProvider), ensuring minimal deviation from standard Laravel workflows.$_SERVER['SERVER_NAME'] (customizable) to dynamically load per-domain configs, enabling zero-code changes for domain-specific logic in most cases.storage/ per domain (e.g., storage/site1_com/), reducing collision risks in file-based systems (e.g., uploaded files, caches).Application, replace QueueServiceProvider, publish config), making it easy to adopt in existing projects.domain:add, domain:remove, domain:update_env) for runtime management, reducing manual config edits..htaccess hacks), though not natively supported.bootstrap/app.php is invasive and may conflict with:
$_SERVER['SERVER_NAME'] by default, which may fail in:
--domain).$_SERVER is unreliable (requires custom detection logic).site1.example.com ≠ site2.example.com; may need regex or custom logic for complex routing.QUEUE_DEFAULT per domain) to avoid job mixing.storage:link is hardcoded to storage/, requiring manual symlinks for per-domain public assets.config:cache generates domain-specific config-*.php files, which may bloat storage for many domains.example.com/site1) vs. subdomains (e.g., site1.example.com)? Does the package support wildcard domains (e.g., *.example.com)?config:cache) recommended for production?APP_ENV) be managed in CI/CD for multi-domain deployments? Will we use domain:update_env or separate .env files?storage/site1_com/).domain:site1:key).storage/site1_com/sessions)..example.com wildcard or subdomain-specific cookies.$_SERVER['HTTP_HOST'] vs. $_SERVER['SERVER_NAME']).QUEUE_DEFAULT per domain).domain:add and validate config/env isolation.| Component | Compatibility | Workarounds |
|---|---|---|
| Laravel Core | ✅ Full support (requires bootstrap override). | Use Laravel 10+ for simpler setup. |
| Queues | ⚠️ Database/SQS/Redis: Manual isolation needed. Sync: No isolation. | Separate QUEUE_DEFAULT per domain; avoid sync driver for multi-tenant. |
| Storage | ✅ Per-domain paths (e.g., storage/site1_com/). |
Manual symlinks for storage:link; customize filesystems.php. |
| Caching | ✅ File/Redis: Isolated. Database: Manual namespacing needed. | Use cache:table with domain-prefixed keys (e.g., domain:site1:key). |
| Auth | ✅ Session isolation via per-domain storage. | Ensure session.driver=file and storage paths are isolated. |
| Horizon | ✅ Supported with one-line override. | Replace HorizonApplicationServiceProvider. |
| SPA/Static Assets | ❌ No native support. | Use .htaccess or custom Nginx rules for domain-specific paths. |
| CI/CD | ⚠️ Manual .env management unless using domain:update_env. |
Script domain:update_env in deployment pipelines. |
Application and QueueServiceProvider before adding domains.domain:add and configure per-domain .env files.queue.php and set up domain-specific workers (e.g., --queue=site1).filesystems.php for custom public paths.domain=site1).domain:add/remove/update_env commands reduce manual config edits..env files minimize merge conflicts in shared repos.config:cache generates domain-specific files, increasing **storageHow can I help you explore Laravel packages today?