Somewhat like dotenv but for PHP.
The goals is to remove all config scattered about in files and have one authoritative source for that config info.
Create a file called production.env in the root of your website. In that file put all configuration. Example:
DB_DSN=mysql:dbname=mydb;host=myhost
DB_USERNAME=myuser
DB_PASSWORD=mypass
Then in your code you can simply access these values via the $_ENV global.
You can also create a "development.env" file if your development config is different (or staging or whatever environments you want to support). Simply make the web-server set the APP_ENV environment variable so it knows which file to load. Example:
APP_ENV=development php -S localhost:5000
Now the PHP scripts will get their config from development.env.
If you don't want to clutter up your web root with a bunch of .env files simply create a "environments" subdirectory and put the files in that directory.
I think you should use "PHP_EOL" instead of "\n".