sneakyimp wrote:I mean shouldn't one just put the credentials in a PHP file as a constant or $config var and require/include that file? Is there something I'm missing here? I expect a lot of noobs might get really confused by this. It doesn't seem very practical to me at all.
You could, but then you would have to keep that PHP file out of version control, e.g., by keeping a template version under version control instead, and then you would need to tell noobs about the template version and how to configure it. In practice, should this configuration file grow to contain other API keys/settings with logic involved, this means that different programmers on the team would be testing the code with possibly critically different configuration files that only they can see. In the environment variables approach, such complex configuration can still go into the configuration file under version control for all to see, with only the values of API keys, passwords, etc, kept out of version control.
Of course, you could try and separate the configuration file from a file that only has the values of API keys, etc, but because it isn't under version control, you depend on programmers not getting lazy and modifying the wrong file in a way that might reasonably be missed in a code review. Perhaps that other file could be in JSON or ini format rather than a PHP file to avoid this, but that could turn out to be just another way to do the environment variables thing, except that you're now loading the "environment" by parsing a data file.
As long as you are not putting credentials under version control and limit access to the production server, I don't think either way provides any real security benefit over the other.