zend框架自动切换生产阶段测试..等 [英] zend framework auto switch production staging test .. etc

查看:74
本文介绍了zend框架自动切换生产阶段测试..等的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要更改什么以从生产切换到暂存.等等.在哪里.. Bootstrap?

What do I change to switch from production to staging.. etc.. and where.. Bootstrap ?

此外,如果有人将其Zend Framework配置为自动从 主机信息来进行生产,分期,测试等.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆