Search code examples
phpcodeignitercodeigniter-hmvc

Modules::run() throwing error: "Unable to locate the specified class: Session.php"


I am using CodeIgniter 3 with wiredesignz HMVC.

I have a controller that renders a view. If I call Modules::run('OtherModule/Controller/Action) from within that view, it shows the following message at the bottom:

Unable to locate the specified class: Session.php

Session is included in the auto-load configuration and works fine in all controllers without references to controllers in other modules. Removing the Modules::run() statement gets rid of the error and the referenced method is an empty dummy, so the error must come from Modules::run() itself.

Google shows a few similar questions but none have been answered. Hopefully someone has figured it out since the last time it was asked. Help is greatly appreciated! Thanks in advance!


Solution

  • I finally figured it out! The controller I tried to call extended MY_Controller, which extended CI_Controller directly. Apparently this works fine for calling methods through the URL, but MX_Controller needs to be extended for Modules::run() to work. Making MY_Controller MX_Controller instead solved the problem.

    I was assuming that I made MY_Controller extend MX_Controller when I created it and it didn't occur to me to check that. Apparently that is a mistake more people make, and now the solution is finally documented.