Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Laravel Multidomain

Laravel Multidomain Laravel Package

gecche/laravel-multidomain

Run multiple HTTP domains from a single Laravel installation. Each domain gets its own env file, storage path, and database, letting different customers share code but keep separate configuration and data.

View on GitHub
Deep Wiki
Context7

Laravel Multi Domain is an extension that lets a single Laravel installation serve multiple HTTP domains. It is ideal when different customers share the same application code but require separate databases, storage and configuration.

Instead of duplicating the application, the package resolves a domain-specific environment file, storage path and database connection per request, keeping each customer fully isolated while maintaining one codebase.

  • Per-domain .env files and configuration
  • Isolated storage directories per domain
  • Dedicated database connections per customer
  • Simple middleware-based domain detection
  • Compatible with Laravel 5.x through 13.x
Frequently asked questions about Laravel Multidomain
How do I install gecche/laravel-multidomain in a Laravel application?
Install it with Composer using a package major that matches your Laravel major, for example 13.x for Laravel 13. Then replace the Illuminate\Foundation\Application import in bootstrap/app.php with the package application class, replace the QueueServiceProvider in config/app.php, and publish the package configuration. If you use Horizon, also add the documented Horizon service-provider replacement. It is not a drop-in dependency, so plan a pilot domain and regression testing before rolling it out.
Which Laravel versions does laravel-multidomain support?
The README includes a compatibility table covering Laravel 5.x through 13.x. From Laravel 10 onward the package major version follows the Laravel major version, so Laravel 11 uses 11.x, Laravel 12 uses 12.x, and Laravel 13 uses 13.x. Older Laravel versions map to different package majors, such as 5.x for Laravel 9 and 4.x for Laravel 8. Because the package overrides Laravel bootstrap internals, validate compatibility explicitly on every Laravel major upgrade.
How does laravel-multidomain detect the current domain?
By default the package determines the domain from $_SERVER['SERVER_NAME']. That works for straightforward web and CLI usage, but it can be unreliable behind proxies, containers, CDNs, or load balancers. In those environments you should provide a custom domain-detection closure using a trusted source such as HTTP_HOST or a forwarded header your infrastructure sets. Test the detection path in production-like infrastructure before relying on per-domain configuration isolation.
Does laravel-multidomain provide full multi-tenancy?
No. It is an infrastructure and configuration isolation layer that gives each domain its own env file, storage path, database configuration, and optional config overrides. It does not provide tenant models, request middleware, row-level scoping, authorization, or guarantees of data isolation. Treat it as a deployment mechanism and handle tenancy enforcement, access control, and data-isolation guarantees separately.
How do I add and configure a new domain with laravel-multidomain?
Use the domain:add Artisan command to register a domain, then create and populate its .env.<domain> file and storage/<domain>/ directory. Validate that the database and any config/domains/<domain>.php overrides resolve correctly. Test web requests, domain-scoped Artisan commands, queue workers, and config caching for that domain before updating your deployment pipeline. Provisioning can be manual, admin-UI driven, or automated through CI/CD depending on your requirements.
How do queue workers and Horizon work with multiple domains in laravel-multidomain?
Queue workers must be started with the correct --domain option; otherwise jobs can run against the wrong tenant configuration. Plan per-domain queue naming and worker topology for queue drivers other than sync. Horizon is supported only if you apply the documented service-provider replacement in addition to the standard QueueServiceProvider swap. Decide deliberately whether queues and Horizon are shared or domain-scoped, and monitor worker configuration closely.
How do I run Artisan commands or config:cache for a specific domain?
The package supports a --domain option across Artisan commands, queue commands, and config:cache. For example, run php artisan config:cache --domain=example.com to generate cache artifacts for that domain. Your deployment automation should generate and invalidate config cache artifacts per domain rather than assuming a single shared cache. Verify the exact command behavior for your Laravel and package versions during the pilot.
What happens if a domain's .env or storage folder is missing?
The package can fall back to the default environment, storage, or database when a domain-specific resource is missing. That silent fallback is convenient during setup but creates a cross-tenant data-exposure risk if it happens in production. Add monitoring and deployment checks that confirm every registered domain has its env file and storage directory. Also review how missing configuration is surfaced in logs and health checks.
Can I use laravel-multidomain behind a load balancer, proxy, or CDN?
Yes, but domain detection needs attention because the default relies on $_SERVER['SERVER_NAME']. Behind a load balancer, proxy, or CDN, that value may not reflect the public hostname. Configure a custom closure that reads a trusted header or HTTP_HOST value set by your infrastructure. Validate the full request path, including TLS termination and forwarded headers, before depending on it in production.
Is laravel-multidomain a good alternative to a full multi-tenancy package, and is it maintained?
It is a strong fit when one Laravel codebase must serve multiple subdomains with isolated env files, storage, and databases, especially for white-label or SaaS deployments. It is not a replacement for a full multi-tenancy framework that handles tenant models, scoping, and authorization. Maintenance is community and MIT based, with a changelog and roughly 1,100 GitHub stars but no commercial SLA and no listed dependents. Define an exit strategy and assign ownership for Laravel and package upgrades before adopting it.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource