samedi 8 juin 2019

Laravel: Use different env files for different domains for multi-tenant app

I am trying to create a multi tenant application.

In other words I have a website, but it has multiple different versions of it with different branding, env variables and database connections. These sites are:

  • sites1.test
  • sites2.test

The easiest way I can think of doing this in Laravel is by having 2 different env files: .env.site1 and .env.site2

This means for artisan commands I can simply do:

  • artisan migrate --env=site1 for site 1 commands
  • artisan migrate --env=site2 for site 2 commands

The issue I have is for HTTP requests. How can I configure laravel so that it:

  • Uses .env.site1 when on site1.test
  • Uses .env.site2 when on site.test

I also think there maybe some issues when caching the .env file.

Also, is there a potentially a better way to do multi-tenancy.



from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2XAe4Tk
via IFTTT

Aucun commentaire:

Enregistrer un commentaire