PHPackages                             adipso/laravel-multidomain - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. adipso/laravel-multidomain

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

adipso/laravel-multidomain
==========================

2.0(3y ago)016MITPHP

Since Mar 10Pushed 3y agoCompare

[ Source](https://github.com/adipso-jerome/php-laravel-multidomain)[ Packagist](https://packagist.org/packages/adipso/laravel-multidomain)[ RSS](/packages/adipso-laravel-multidomain/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

Add multi-domain support in Laravel
===================================

[](#add-multi-domain-support-in-laravel)

Let's get started
-----------------

[](#lets-get-started)

First of all, include this library into your Laravel projet dependencies, using the following command:

```
composer require ludovicm67/laravel-multidomain`
```

Create a file called `config.yml` at the root of your project, with something like:

```
fallback_url: http://localhost/
supported_domains:
  localhost:
    site_name: Localhost
    database:
      hostname: localhost
      username: root
      password:
      database: db
  amazing.localhost:
    site_name: Amazing!
    database:
      hostname: localhost
      username: amazing
      password: wow
      database: amazing
```

If the current hostname is not in the `supported_domains` list, the app will redirect to the `fallback_url`.

One special case: if the asked domain is starting with `api.` and if in the configuration file there are only a version without the `api.`, this last one will be used.

You can add all properties as you wish; here we will for example see how to have a different database for each domain.

To get started, update the `bootstrap/app.php` file to load the configuration, as follow:

```
