no-framework-tutorial icon indicating copy to clipboard operation
no-framework-tutorial copied to clipboard

Environment Switcher

Open PatrickLouys opened this issue 11 years ago • 8 comments

Explain how to: config file that is in .gitignore

PatrickLouys avatar Nov 06 '14 21:11 PatrickLouys

I love the config folder idea with config files, and optionally have config/{environment} folders that overwrite any config in the main folder. The {environment} could be set in .env, which would be a good solution for PatrickLouys/no-framework-tutorial/issues/20 (with the appropriate wrapper/interface of course)

phillipsharring avatar Nov 05 '17 06:11 phillipsharring

The last full time development job I had, we had a config system that used .INI files. One for Dev, one for QA and one for Prod. Also each developer had their own INI that would merge with the Dev. It used apache env variables. I'll have to look for example code on my old hard drives.

ellisgl avatar Nov 05 '17 06:11 ellisgl

Check out https://github.com/vlucas/phpdotenv

Lots of projects do it with an ignored .env and commited .env.example where new env keys are added. I mentioned this on #20 too. Then the .env stuff could be referenced in the config files. Multiple developers could have their own thing with the folder idea I mentioned above. The config/db.php file could be production, but config/phil/db.php would overwrite that if the environment was set to "phil" - just an example. I've seen the ini solution too, esp. in Java projects. While I'm not opposed, I think it muddies the repo to have an individual's settings checked in. Just a preference.

phillipsharring avatar Nov 05 '17 06:11 phillipsharring

I found some very old code (was making a boilerplate "framework" for that job). read.me has the info for the apache configs. library\X5\Config.php goes over how the INI's were handled. I guess the thing was that it has "macros" built in. x5.zip

I'm not saying this is the way to do it, i'm just showing one way of doing configs.

ellisgl avatar Nov 05 '17 07:11 ellisgl

@ellisgl Hey! looks cool. A lot of effort went into that. Thanks for sharing.

phillipsharring avatar Nov 05 '17 12:11 phillipsharring

@philsown so... decided to remake that mess of old code... https://github.com/ellisgl/GeekLab-INICONF

ellisgl avatar Nov 10 '17 07:11 ellisgl

Can we close this?

ellisgl avatar Jul 26 '20 21:07 ellisgl

Yes.

phillipsharring avatar Jul 28 '20 18:07 phillipsharring