Weave Code
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 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.

View on GitHub
Deep Wiki
Context7

Laravel App on a subdomains, multi-tenancy setting

Frequently asked questions about Laravel Multidomain
How do I install Laravel MultiDomain in a Laravel 11+ project?
For Laravel 11+, installation is simplified—just add the package via Composer (`gecche/laravel-multidomain`) and publish the config. No manual `app.php` edits are needed, as the package auto-detects domains via `$_SERVER['SERVER_NAME']`. Follow the [README setup guide](https://github.com/gecche/laravel-multidomain#installation) for Laravel 11+.
Can I use this package for subdomains like `tenant1.app.com` instead of root domains?
The package defaults to root domains (`tenant.com`), but subdomains require middleware to override `$_SERVER['SERVER_NAME']`. Use the `domain_detection_function_web` config to customize detection (e.g., extract subdomains via regex). For wildcard DNS, ensure your load balancer forwards the `Host` header correctly.
How do I configure per-domain databases without duplicating the app?
Store domain-specific `.env` files in `config/domains/` (e.g., `tenant1.php`). The package automatically loads the correct `.env` based on the domain. For databases, use separate schemas or tables, and configure `config/database.php` to dynamically switch connections per domain using the `domain()` helper.
Does this package support Laravel Horizon for queue workers?
Yes, but you’ll need to override the `HorizonServiceProvider` to include the `--domain` flag for per-domain queue workers. The package extends Laravel’s queue system to support domain-specific configurations, so Horizon will respect the active domain if configured properly. Check the [README](https://github.com/gecche/laravel-multidomain#horizon) for the override steps.
How do I handle storage paths for each domain (e.g., uploads, logs)?
The package dynamically sets the `storage_path()` and `public_path()` per domain by loading `config/domains/{domain}.php`. For shared storage (e.g., S3), configure the domain-specific `.env` to point to the correct bucket. Note that `php artisan storage:link` may require manual symlinks for per-domain paths—see the [README workarounds](https://github.com/gecche/laravel-multidomain#storage-symlinks).
Will this package work with Laravel Forge or Envoyer for deployments?
Yes, but you’ll need to version-control domain-specific configs (e.g., `config/domains/*.php`) and exclude sensitive `.env` files. Use Forge/Envoyer’s environment variables to inject domain-specific settings at deploy time. For shared hosting, ensure your server passes the `Host` header correctly for domain detection.
How do I test multi-domain functionality in my Laravel app?
Use the `domain()` helper to switch contexts in tests (e.g., `config(['domain' => 'test-tenant'])`). The package provides `php artisan domain:list` to verify registered domains. For HTTP tests, mock `$_SERVER['SERVER_NAME']` or use middleware to simulate domain requests. Example: `putenv('HTTP_HOST=test-tenant.com');` before tests.
What’s the best way to isolate queues for each domain (e.g., Redis or database queues)?
Configure per-domain queues by setting `QUEUE_CONNECTION` in domain-specific `.env` files (e.g., `tenant1_redis` for Redis or `tenant1_mysql` for database queues). For shared Redis, use separate channels or namespaces (e.g., `tenant1:jobs`). The package respects `QUEUE_DEFAULT` per domain, so ensure your queue workers are launched with `--domain=tenant1`.
Can I use this package with Laravel 5.5, or should I upgrade?
The package supports Laravel 5.5–13.x, but newer versions (11+) simplify setup. If you’re on Laravel 5.5, pin to `gecche/laravel-multidomain:1.1.x` and follow the legacy [installation guide](https://github.com/gecche/laravel-multidomain#laravel-55). Upgrading to Laravel 10+ is recommended for long-term maintenance and compatibility with newer Laravel features.
How do I debug issues with domain detection failing (e.g., load balancer rewriting Host header)?
Check the `domain_detection_function_web` in `config/multidomain.php` to customize how domains are detected. For load balancers, use a closure like `return request()->getHost();` or parse the `X-Forwarded-Host` header. Log the detected domain early in your middleware to verify: `Log::debug('Detected domain:', ['domain' => domain()]);`.
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.
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
ecotone/kafka
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata