代码点火器模块扩展- MX_Router::_set_default_controller()的访问级别必须是publi


code igniter Modular Extensions - Access level to MX_Router::_set_default_controller() must be public (as in class CI_Router)

我得到流行的模块化扩展- HMVC安装从

https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc

并设置它与codeigniter 2.2.2 BUT当一切都应该工作正常,我得到这个错误

MX_Router::_set_default_controller()的访问级别必须在C:..'application'third_party'MX'Router.php的第241行中为public(与类CI_Router一样)

解决方案1

我必须在Router.php中更改几个方法的可见性,所以我将以下方法从protected更改为public以固定

_set_default_controller()
_set_request()
_set_default_controller()

,它几乎工作,但现在我得到一个警告上面熟悉的欢迎到CodeIgniter消息

Message: Undefined property: MY_Router::$translate_uri_dashes

所以我将这个属性包裹在if不为空的位置以绕过这个属性,像这样

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)和第三方文件夹(MX)从预配置版本的ci 2.0.3(上面的链接)放在ci 2.2.2的相应位置,它会正常工作。