Laravel Multidomain Package


November 7th, 2019

Laravel Multidomain Package

Laravel Multidomain is a package by @gecche that allows a single Laravel Installation to work with multiple HTTP domains:

There are many cases in which different customers use the same application in terms of code but not in terms of database, storage, and configuration.

This package gives a very simple way to get a specific env file, a specific storage path, and a specific database for each such customer.

Once you finish the installation and setup outlined in the readme, you can use package commands to manage domains:

# Adding a domain
php artisan domain:add
php artisan domain:add
# Removing a domain
php artisan domain:remove

When you add a domain, the .env configuration file is created for that specific domain:

php artisan domain:add
# Generates the following configuration file

You can also list domains with the domain:list command:

php artisan domain:list

Be sure to check out the full documentation of the package before deciding to use this package. This package provides an extended kernel and requires some buy-in in the methodology of this approach. Just make sure you evaluate the design of this package (and any package for that matter) for your use-case.

You can learn more about this package, get full installation instructions, and view the source code on GitHub at gecche/laravel-multidomain.

This package was submitted to our Laravel News Links section. Links is a place the community can post packages and tutorials around the Laravel ecosystem. Follow along on Twitter @LaravelLinks

Filed in:

Paul Redmond

Full stack web developer. Author of Lumen Programming Guide and Docker for PHP Developers.