解决方案 1
我不得不更改 Router.php 中的几个方法可见性,所以我将以下方法从更改protected
为public
修复它
_set_default_controller()
_set_request()
_set_default_controller()
它几乎工作了,但现在我在熟悉的 Welcome to CodeIgniter 消息上方收到警告
Message: Undefined property: MY_Router::$translate_uri_dashes
所以我把这个属性包裹在一个 if not empty 周围绕过这个属性像这样
if(!empty($this->translate_uri_dashes))
{
if ($this->translate_uri_dashes === TRUE)
{
foreach(range(0, 2) as $v)
{
isset($segments[$v]) && $segments[$v] = str_replace('-', '_', $segments[$v]);
}
}
}
现在它可以工作了!
解决方案 2
有一个现成的 HMVC-ci 可以从
http://lab.clearpixel.com.au/2011/10/modularise-your-codeigniter-2-applications-with-modular-extensions-%E2%80%93-hmvc/
但它是 ci 2.0.3 版本而不是 ci 2.2.2
解决方案 3(最佳)
如果您将核心文件(MY_Loader 和 MY_Router)和 ci 2.0.3 的预配置版本(上面的链接)中的第三方文件夹 (MX) 放在 ci 2.2.2 中的相应位置内,它将正常工作。