我正在使用codeigniter v3.1.10
,我有两个项目的域名分别为abc.example.com
和xyz.example.com
。我知道根据环境生产或开发情况在codeigniter中,我们可以在配置文件夹中添加文件夹application/config/production
和application/config/development
,并在其中包含各自的文件。在SO中找到一个示例:-multiple environments with codeigniter,使我们可以在development/production
文件夹内添加application/config
文件夹。
但是我正在寻找的是domain specific folders inside application/config folder
。有没有一种方法可以放置两个文件夹,例如application/config/abc.example.com
和application/config/xyz.example.com
,其中包含config.php, database.php and constant.php
文件。
根据您的要求,您需要多个子域配置。例如,对于子域abc.exmaple.com
,要加载abc
配置文件夹。对于子域xyz.exmaple.com
,要加载xyz
配置文件夹。
在您的index.php
中
list($subdomain,$host) = explode('.', $_SERVER["SERVER_NAME"]);
define('ENVIRONMENT',$subdomain);
在下面的switch..case
中,以您的子域为例
switch (ENVIRONMENT)
{
...
...
case 'testing':
case 'production':
case $subdomain:
....
}
现在根据您的子域在config文件夹下创建一个文件夹,然后在此处进行所需的配置。