Posts Tagged ‘development’

Marking a machine as development machine

There are many times when I need to just run certain codes in the development machine or in the production machine. In order to do so, we can just check for the machine name:

if($_SERVER['SERVER_NAME'] == 'machine_name') {
  /run the codes inside here

But this is quite difficult when more than one development machine is involved because it will have different machine name. I have encountered cases when a certain code should only be run in production machine but because my test machine has different name, the code was run when I am testing the code.

Hence this piece of code that I encountered when I learnt about Zend Framework is quite useful for me:

if(getenv('APPLICATION_ENV') == 'development') {
  //run the codes inside here

Then just put this additional line to .htaccess file:

SetEnv APPLICATION_ENV development

All the development machines need to have the additional line in their .htaccess file.