Created
August 27, 2012 08:36
-
-
Save wangshijun/3486700 to your computer and use it in GitHub Desktop.
php: environment dependent config autoloading Yii startup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
define("APP_DIR", dirname(dirname(__FILE__))); | |
define("WWW_DIR", dirname(APP_DIR)); | |
define("CONF_DIR", APP_DIR . "/protected/config/"); | |
$clusters = require_once(CONF_DIR . "clusters.php"); | |
$mainConfig = require_once(CONF_DIR . "main.php"); | |
// 根据应用程序所在环境加载配置, 默认为develop | |
if (isset($clusters["product"]) && in_array(strtolower(php_uname("n")), $clusters["product"])) { | |
defined("YII_DEBUG") || define("YII_DEBUG", false); | |
defined("YII_TRACE_LEVEL") or define("YII_TRACE_LEVEL", 0); | |
$clusterConfig = require_once(CONF_DIR . "conf.d/product.php"); | |
} else { | |
defined("YII_DEBUG") || define("YII_DEBUG", true); | |
defined("YII_TRACE_LEVEL") or define("YII_TRACE_LEVEL", 3); | |
$clusterConfig = require_once(CONF_DIR . "conf.d/develop.php"); | |
} | |
require_once (WWW_DIR . "/thirdlib/yii/framework/yii.php"); | |
Yii::setPathOfAlias("jike", WWW_DIR . "/jikelib"); //jike namespace | |
Yii::setPathOfAlias("third", WWW_DIR . "/thirdlib"); //third namespace | |
Yii::import("jike.yiiext.*"); //import jike.yiiext | |
Yii::import("third.*"); //import third | |
$GLOBALS ["THRIFT_ROOT"] = APP_DIR . "/protected/lib/thrift/"; | |
// Run Application | |
$config = CMap::mergeArray($mainConfig, $clusterConfig); | |
Yii::createWebApplication($config)->run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment