I’d like to be able to distinguish my dev servers from production (and beta testing) servers automatically in the most efficient way, and without relying on something like the HTTP_HOST. I would this to be transparent to the other developers, so they don’t have to worry about it.
I’m using pre-compiling css and compressing js when I deploy to production, but I want the uncompressed js (and on-the-fly complied css) on production. A simple “development” flag would be enough to distinguish them, but what is the best way to get this variable into the development environment without wasting resources in production?
My current plan is to dynamically rewrite a php (or ini file, to be parsed with parse_ini_file) file as part of our deploy process, setting developer to false (I may rewrite this file anyway to set the new filenames for the compiled css and js). However, I’m worried that if something unexpected were to go wrong with the deploy script, as written, there might be some risk that the developer mode would be pushed to production. In other words, I want there to be something specific about the development environments such that there is no risk that a production system would be mistaken for a development system.
I considered using separate user.ini files to set custom “development” flags to distinguish this, but I had trouble getting that to work, and wanted to see if there was a better solution before I spent any more time on that.
What you could do is set the flag in our httpd.conf file on each server. So for your Dev box, you can just add this to your apache conf
SetEnv APPLICATION_ENV development. For your production box, do the sameSetEnv APPLICATION_ENV production.In your php application config, you can do something like this: