Search code examples
zend-frameworkapplication-settings

How to dynamically change the server environment settings of application.ini in zend


I have created a new project in Zend. Now it runs on the settings value under [production]. I would like my application to run the settings value under [development : production]. I require to do this dynamically by checking my host name. How can I do this? Also I need to know from my controller, under which settings I am running ([production] or [development : Production] or any other).

Kindly help


Solution

  • In your index.php file you should insert something like this:

    defined('APPLICATION_ENV')
        || define('APPLICATION_ENV', ($_SERVER['SERVER_ADDR'] != '127.0.0.1' ? 'production' : 'development'));
    

    See PHP $_SERVER