Configurable path for .env file |
Hi,
I have a reorganized structure for the application and currently, I can run several domains for one application. I would need to change the location of the .env file (finally the file for each domain separately), but from what I see it is not possible at the moment. Does anyone have an idea for this?
This seems to be working for me.
Keep all of your .env files in the rootpath (along side system and app folders) Create a duplicate .env file and rename it to whatever suits your needs. (example: .env-dev) In your /public/index.php add your custom env file name to a constant variable at the top: PHP Code: define('ENVFILE', '.env-dev'); // constant name and file name are your choice In /system/bootstrap.php change PHP Code: $env = new DotEnv(ROOTPATH); to PHP Code: $env = new DotEnv(ROOTPATH, ENVFILE); Boom! With this change, if you have addon/sub domains, you would create a new env file in the rootpath. (example: .env-new) In /public/new/index.php add your custom env file name to a constant variable at the top: PHP Code: define('ENVFILE', '.env-new'); Your addon / sub domain should now be looking at its own env file. Maybe someone can chime in and give me any insight on the downside to doing it this way but it works! |
Welcome Guest, Not a member yet? Register Sign In |