【问题标题】:Codeigniter HMVC loading custom config fileCodeigniter HMVC 加载自定义配置文件
【发布时间】:2014-01-30 18:27:19
【问题描述】:

我在 CodeIgniter 中使用 HMVC 扩展。我有一个像

这样的模块
 moduleName
     config 
         config.php
         routes.php
     controller
         test.php
     models
         etc..

来自test.php 我试图从上面的模块文件夹加载自定义配置项。 但它不起作用。我像class Test extends MX_Controller {} 一样扩展我的课程@

我尝试从模块文件夹之外的默认配置文件夹和its working加载配置项

根据this post,模块配置应该在模块初始化时加载。但它不起作用。

我在这里错过了什么?

【问题讨论】:

    标签: php codeigniter codeigniter-2 codeigniter-hmvc


    【解决方案1】:

    默认情况下,Codeignitor 不会从模块文件夹加载配置。它在 application/config 文件夹上的外观,首先它在 ENVIRONMENT 文件夹上的外观,以防你有 application/config/development .....

    要从模块中加载配置,您可以使用

    $this->load->config('../models/config/XXX.php')  
    

    或者你必须扩展 Config 类来修改你的方式

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-11
      • 2010-10-05
      • 2020-08-02
      • 2014-01-15
      相关资源
      最近更新 更多