What do I change to switch from production to staging.. etc.. and where.. Bootstrap ?
Also, Curious if anyone has configured their Zend Framework to automatically switch from production, staging, test.. etc based on Host information..
example..
if (hostname = 'prodServer') ... blah
if (hostname = 'testServer') ... blah
I'm new to Zend but I typically configure my projects to automatically switch run environments based on the host information.
thanks
The best way that I saw is:
I also tried host named configs files:
but the first approach is much better.
We define an environment variable (ENVPHP), and use this in our XML configuration files, so the correct DB parameters are loaded as long as you define the correct ENVPHP environment variable. Using XML you can extend (or override) your common parameters with those for the specific environments.
ie. the configuration looks as follows :
And to load the configuration, I have the following in my bootstrap (well, actually in an Application singleton class) :
In PHP code if I want to do some things only for specific environments then I use Application::getEnv() to check what environment I'm in and execute the code I want according to it.
BTW The ENVPHP environment variable can be set in your apache configuration file using ie.
SetEnv ENVPHP "dev"
within your VirtualHost container. For CLI PHP scripts you should set it as an OS environment variable...That work for me in .htaccess
Then in my application.ini
Assuming that you are using APPLICATION_ENV as part of Zend_Application, then you could add this in either your .htaccess or main Apache config (assuming Apache is in use - should still be possible with different Web servers too).
For example, in your .htaccess/config (assumes mod_setenv):
Then ensure that APPLICATION_ENV is set in index.php by using:
This is added by Zend_Tool if you use it to generate the project.