I got CI 2.1 + Modular Extensions 5.4 + Ion Auth 2, all working.
Since I did not see any specific information about this and the materials that I saw, had a bunch of things, such as routing and stuff, that I could not work the way they were done, I decided to share what I did for this.
At first I struggled with this, but then I had to sit back and think about what was happening.
After that, in fact, it was pretty straightforward, only a couple of mistakes ...
The steps I took to get ION AUTH to work with CodeIgniter + MX HMVC
Install CodeIgnter (I actually used an existing project that I was working on, so it wasnโt a clean clean install. I uninstalled โindex.phpโ and HMVC already installed the recommended method. Ion Auth anyway.)
Get the latest version of Ion Auth.
Instead of setting Ion Auth to application/third_party , unzip it and rename the resulting directory to auth . Put it in application/modules , which will lead to application/modules/auth .
Run Ion Auth sql to configure the tables.
In application/config/autoload.php update the line to:
$autoload['libraries'] = array('database','session');
In modules/auth/libraries/Ion_auth.php update the lines in __construct to:
$this->ci->load->config('auth/ion_auth', TRUE); $this->ci->load->library('email'); $this->ci->load->library('session'); $this->ci->lang->load('auth/ion_auth'); $this->ci->load->model('auth/ion_auth_model')
In modules/auth/models/ion_auth_model.php update the lines in __construct to:
$this->load->config('auth/ion_auth', TRUE); $this->load->helper('cookie'); $this->load->helper('date'); $this->load->library('session'); $this->lang->load('auth/ion_auth');
Modify the auth controller ( modules/auth/controllers/auth.php ) to extend MX_Controller instead of the standard CI_Controller .
Now, in auth.php , make sure you change all $this->data to $data - (be sure to read about it below!).
Move the files and directories in modules/auth/views/auth to modules/auth/views , which will lead to modules/auth/views without the bottom level auth dir - (be sure to read about it below!).
Add the route.php file to modules / auth / config and add the following line:
$route['auth/(:any)'] = "auth/$1";
Now go to http://yoursite/auth and everything should be fine!
Gotchas
First, do not use AUTOLOAD LIBRARIES OR MODELS in the file application/config/autoload.php . Make them explicit in the modules using $this->load->library("whatever") , etc.
It delayed me a bit.
I forgot to mention that in my current installation I already deleted index.php from the url and I have a .htaccess file in my installation database. If something doesn't work, maybe something with RewriteBase is here. This .htaccess I use:
#
===================================
When I updated the modules /auth/controllers/auth.php to extend the MX_Controller instead of CI_Controller, after that I got a number of errors. The first of these errors:
A PHP Error was encountered Severity: Notice Message: Undefined property: CI::$data Filename: MX/Controller.php
To fix this error, I changed all $this->data to $data in the auth.php controller.
After fixing this problem, when I go to auth , I get this error:
Unable to load the requested file: auth/login.php
Apparently, he cannot find the view files in his own views directory. Ahh. Not quite right, though thinking about it. The reason is that the search for module/file_to_view and file_to_view should be in views ! Not in auth/views/auth !! So, we need to move all the values โโfrom auth dir to the views directory!
After that, everything works fine! I can overload models, libraries, and controllers in other modules, and I can execute Modules :: run () in views and everything else!
Hope this helps someone else. Good luck