October CMS 2.x: using custom .env files, e.g., .env.canada

Hi All,

I have a question… can I name the .env file anything, or must it be .env for the production environment?

I’m thinking of a way to add multi-country support to the codebase, and my idea is to use a URL prefix (e.g., /ca/ for Canada, /eg/ for egypt, etc) to determine which .env file to use. My naming scheme would be something like .env.canada, .env.egypt, etc.

I already have a prototype working, and for Canada I’m setting $_SERVER[‘APP_ENV’] = ‘canada’. This causes the system to use the .env.canada file. All that works, I just need to know if using .env.canada will work for production. Is the any place within the codebase looking specifically for APP_ENV to be “production”? When I searched the codebase, I could not find any such checks. But I thought I’d just ask here among the seasoned who may have tried using a .env.something file in a production environment before.

Thanks!

Hey @Jinjo
Glad to hear it works!

It should work in production. This is a legitimate way to handle multi-tenancy deployments. The docs cover this here: