Managing Environment Variables in PHP

Now I work with more programming languages, I start to miss features from other languages when I come “home" to PHP. One that I hadn’t seen in PHP before I saw it in other languages such as Node.js (I think Ruby had the original implementation) was: a way to easily control setting your environment variables, particularly in development. In Node.js, the dotenv library is great for this; handily in PHP vlucas has already created phpdotenv so we are all set to apply these tricks to PHP applications!
Managing Environment Variables
The overall idea is that your code can read variables from a local text file rather than from the actual environment variables. This makes it easier to switch projects because you can write a file per project and not have to re-export environment variables (or wonder why the variables are wrong if you didn’t start a new shell when switching projects). Also since I often write code for other people to use, such as example applications or starter kits, the .env file provides a clear list of the values they need to set for the thing to work.

Link: https://dzone.com/articles/managing-environment-variables-in-php?utm_medium=feed&utm_source=feedpress.me&utm_campaign=Feed%3A+dzone%2Fwebdev