johnstontrav's avatar

setup custom .env based on header token

Hi,

Single common microservice will have many different DB's, so how can I setup use a different .env based on a JWT token from client?

Cheers, Trav

0 likes
3 replies
pmall's avatar

I dont think you can change the .env. You should find another way of setting your db connection

rdelorier's avatar

You should be able to load an additional .env to override vars with Dotenv::load(DIR.'/../');

mhankins's avatar

Behind the scenes, Laravel is using https://github.com/vlucas/phpdotenv which you might be able to leverage for your own needs. For example Dotenv::load(__DIR__); and also look at nested values if your sub .env file is going to have a persistent naming schema.

Please or to participate in this conversation.