Applying CodeIgniter Modular Separation / HMVC 5.4 on an existing project with a custom core controller

For my current job at the University of Kassel, I am currently modularizing an existing PHP project that is using the CodeIgniter Framework (which I like very much, by the way)

I found this very helpful “extension” to CodeIgniter, called “Modular Extensions – HMVC version 5.4” whichs documentation is a little chaotic and incomplete.

One problem that I stubled upon, was that we created our own core controller, having our controllers not extend CI_Controller, but our own controller (which is called MY_Controller) in most setups. BUT: We set the $config[‘subclass_prefix’] to something like ‘OwnPrefix_’. I thought the whole extension would not work, but i found out, that you will have to rename the two files MY_Router.php and MY_Loader.php in the application/core/ ‘MY_’ prefix to your own prefix.

Then I had my OwnPrefix_Controller extend MX_Controller and everything seems to work so far!

Leave a Reply

Your email address will not be published. Required fields are marked *