zend框架自动开关生产分期测试..等 [英] zend framework auto switch production staging test .. etc
问题描述
从生产切换到登台,我需要改变什么......等等......以及在哪里...... Bootstrap?
What do I change to switch from production to staging.. etc.. and where.. Bootstrap ?
另外,好奇是否有人将他们的 Zend 框架配置为自动切换基于主机信息的生产、登台、测试等..
Also, Curious if anyone has configured their Zend Framework to automatically switch from production, staging, test.. etc based on Host information..
示例..
if (hostname = 'prodServer') ... blah
if (hostname = 'testServer') ... blah
我是 Zend 的新手,但我通常将我的项目配置为自动切换根据主机信息运行环境.
I'm new to Zend but I typically configure my projects to automatically switch run environments based on the host information.
谢谢
推荐答案
假设您使用 APPLICATION_ENV 作为 Zend_Application 的一部分,那么您可以将其添加到您的 .htaccess 或主 Apache 配置中(假设 Apache 正在使用中 - 应该仍然可以使用不同的 Web 服务器).
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).
例如,在您的 .htaccess/config(假设 mod_setenv)中:
For example, in your .htaccess/config (assumes mod_setenv):
SetEnvIf HTTP_HOST abc.example.com APPLICATION_ENV=production
SetEnvIf HTTP_HOST def.example.com APPLICATION_ENV=staging
SetEnvIf HTTP_HOST ghi.example.com APPLICATION_ENV=development
然后使用以下方法确保在 index.php 中设置了 APPLICATION_ENV:
Then ensure that APPLICATION_ENV is set in index.php by using:
// Define application environment
defined('APPLICATION_ENV') || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
如果您使用 Zend_Tool 来生成项目,它会添加它.
This is added by Zend_Tool if you use it to generate the project.
这篇关于zend框架自动开关生产分期测试..等的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!