Skip to main content
Back to packages
1,118 GitHub stars

gecche/laravel-multidomain

View on GitHub

Description

This package allows a single Laravel installation to work with multiple HTTP domains. Simple way to get a specific env file, a specific storage path and a specific database for each such customer.

This package adds three commands to manage your application HTTP domains:

domain.add artisan command

The main command is the domain:add command which takes as argument the name of the HTTP domain to add to the application. Let us suppose we have two domains, site1.com and site2.com, sharing the same code.

We simply do:

php artisan domain:add site1.com

and

php artisan domain:add site2.com

These commands create two new environment files, .env.site1.com and .env.site2.com, in which you can put the specific configuration for each site (e.g. databases configuration, cache configuration and other configurations, as usually found in an environment file).

The command also adds an entry in the domains key in config/domains.php file.

In addition, two new folders are created, storage/site1_com/ and storage/site2_com/. They have the same folder structure as the main storage.

Customizations to this storage substructure must be matched by values in the config/domain.php file.

Related Content on Laravel Daily

Video

Recent Courses on Laravel Daily

Queues in Laravel 13

18 lessons
1 h 12 min read

How to Build Laravel 13 API From Scratch

30 lessons
1 h 23 min

How to Structure Laravel 13 Projects

16 lessons
1 h 32 min read