Reputation: 2243
I have a Laravel application running at www.myapp.com
with its own logos and all, the logo file location is defined in a .env file.
Now I want to have a white-label of www.myapp.com
application on www.whitelabel.com
with its own logo.
I need to have two different .env files that need to be loaded at runtime e.g.
- for www.myapp.com
in URL it should use .myapp.env
file
- and for www.whitelabel.com
it should use .whitelabel.env
file.
Is this possible in Laravel 5.1, if yes how?
Upvotes: 0
Views: 883
Reputation: 2243
I solved it using Dotenv::load
function in Laravel 5.1. Add following code in bootstrap/app.php
before return $app;
$environmentPath = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR;
$environmentFile = null;
switch (getenv('HTTP_HOST')) {
case 'whitelabel.com':
$environmentFile = '.whitelabel.env';
break;
}
if (!empty($environmentFile) && file_exists($environmentPath . $environmentFile)) {
Dotenv::load($environmentPath , $environmentFile);
}
Hope it help someone.
Upvotes: 3