I would like to use different configuration file based on IP(IP to region)
I am having problem setting custom configuration files, and not with the IP lookup/database.
How can I implement such a feature in Yii?
I would like to use different configuration file based on IP(IP to region)
I am having problem setting custom configuration files, and not with the IP lookup/database.
How can I implement such a feature in Yii?
Put something like the following into your index.php:
$webRoot=dirname(__FILE__);
if($_SERVER['HTTP_HOST']=='localhost'){
define('YII_DEBUG', true);
require_once(dirname($webRoot).'/framework/yii.php');
$configFile=$webRoot.'/../app/config/dev.php';
}
else {
define('YII_DEBUG', false);
require_once(dirname($webRoot).'/framework/yiilite.php');
$configFile=$webRoot.'/../app/config/production.php';
}
$app = Yii::createWebApplication($configFile)->run();
Of course you’ll need to replace conditions to ips checking.