Namal
Namal

Reputation: 2071

Laravel Domain specific configurations

I have a single app in Laravel and I don't want install it separately for each client. So I need to detect the client from a sub domain and load their configurations according to that.

How do I do that from Laravel 5.2? Appreciate your experienced answers. Is my approach is good or should it better install separately?

Actually I need to detect the client before he logged in. So I can load a different login view for each client with logos etc.

Upvotes: 1

Views: 263

Answers (1)

huuuk
huuuk

Reputation: 4795

It's good approach to keep all client sensitive configs in .env files and use DotEnv as it does Laravel

For example

client1 .env

CLIENT_NAME=Nick  
[email protected]

client2 .env

CLIENT_NAME=Tom  
[email protected]

Then in your config/app.php for example

'client_name' => env('CLIENT_NAME', 'Here you can set default value'),

'client_email' => env('CLIENT_EMAIL', 'Here you can set default value'),

Now you can access them something like

$clientName = config('app.client_name');

$clientEmail = config('app.client_email');

Upvotes: 2

Related Questions