我使用Codeigniter 3.1.0,并在其中安装了模块化的HMVC。下面是简要的文件层次结构:
-application
--controllers (default controllers folder non hmvc)
---hello_one.php
--modules
---hello_two
----controllers
-----hello_two.php
----models
----views
安装HMVC模块后,我可以访问hello_two控制器,但我不能访问hello_one默认(非HMVC)控制器,除非我扩展MX_Controller扩展CI_Controller在MX文件夹。
为什么?安装出错了吗?
首先你需要确保你的文件和类名的第一个字母只有大写的控制器,模型,库
http://www.codeigniter.com/user_guide/general/styleguide.html命名
http://www.codeigniter.com/user_guide/general/styleguide.html class-and-method-naming
hello_one.php
hello_two.php
改为
Hello_one.php
Hello_two.php
路线
$route['default_controller'] = 'home_one';
如果HMVC为默认控制器
$route['default_controller'] = 'hello_two/home_two/index';
$route['default_controller'] = 'module/controller/function';