2013-01-23 117 views
2

我想在1 codeigniter应用程序下创建多个应用程序,但其中一些应用程序会共享相同的配置,如数据库配置。在codeigniter中的多个应用程序之间共享配置

-application 
    -config 
    -models 
    -project_1 
    -config 
    -controllers 
    -models 
    -project_2 
    -config 
    -controllers 

是有可能加载应用程序文件夹的第一级上的配置,并查找应用程序级别的文件夹,如果配置文件不存在?我知道这是可能的,当我通过使用add_package_path()手动加载配置,但自动加载不起作用。

+0

你有没有想过aboutlooked在环境? http://ellislab.com/codeigniter/user-guide/libraries/config.html http://ellislab.com/codeigniter/user-guide/general/environments.html – Rooneyl

回答

1

您应该使用软件包:

http://ellislab.com/codeigniter/user-guide/libraries/loader.html

我倾向于创建一个包Web根目录中称为 '份额',即包/股

在您的包文件夹中,您可以创建类似于核心CI应用程序配置,助手,模型,视图等的文件夹结构。

说你要只有一个数据库文件,你可以把里面包/股/ config中的数据库配置文件,并使用你的应用程序中以下数据库文件中调用这个文件:

include_once(FCPATH . 'packages/share/config/database.php'); 
2

为什么不把它简单:

<?php 

    // This app has no config. Use the shared one 
    require_once('/path/to/common/config.php'); 
相关问题