Reputation: 4457
I 'm trying to set up modularity on my CI 3 installation, but seems not working. I'm using wiredesignz package found here under the "Branches" tab.
The steps I did:
Copied this line of code in application/development/config.php ( I have moved config.php under development folder )
// set location for modules $config['modules_locations'] = array( APPPATH.'modules/' => '../../modules/', );
Created
application - modules -- controllers --- Test.php -- models -- views --- test.php
with my Test.php like this
class Test extends CI_Controller {
function __construct() {
parent::__construct();
}
public function index() {
$this->load->view('test');
}
}
just to check that is working ok, but when I hit on my browser localhost/myapp/test, I get a 404 error.
Any ideas what I'm doing wrong?
Upvotes: 4
Views: 8379
Reputation: 190
Just in case anyone still has this issue, even though the file/folder structure is correct, in my case, and it took me a few days to figure it out, there were 2 additional issues:
Upvotes: 0
Reputation: 31
Add this lines in application/third_party/MX/Loader.php after line 307,
protected function _ci_object_to_array($object)
{
return is_object($object) ? get_object_vars($object) : $object;
}
Works fine.
Upvotes: 0
Reputation: 3802
HMVC Modules folder for Codeigniter 3 How to implement HMVC in codeigniter 3.0?
I tested works
Upvotes: 2
Reputation: 116
Have you tried to put the controllers and views in test folder inside the modules folder?
Means something like that
application/modules/test/controllers/Test.php
Upvotes: 2
Reputation:
Try change CI_Controller to this MX_Controller
class Test extends MX_Controller {
function __construct() {
parent::__construct();
}
public function index() {
$this->load->view('test');
}
}
But I think you also need sub modules folder example
modules => admin => controllers
modules => admin => controllers => Test.php
modules => admin => models
modules => admin => views
modules => admin => views => test.php
Make sure you configure your routes
Example:
$route['test'] = "admin/test/index";
Upvotes: 0