4

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:

  1. Copied MY_Loader & MY_Router in application/core
  2. Copied MX folder in application/third_party
  3. 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/', );

  4. 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?

5
  • .htaccess? Have you tried with localhost/myapp/index.php/test? Commented Apr 10, 2015 at 16:56
  • @Tpojka I have tried both ways, nothing works Commented Apr 10, 2015 at 17:12
  • Yup, you have been extending CI_Controller instead MX_Controller. Check one answer bellow. Commented Apr 10, 2015 at 17:16
  • Did you obey all 12 installation points from here? Commented Apr 10, 2015 at 17:47
  • Check your routes.php file Commented Apr 11, 2015 at 9:56

5 Answers 5

2

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

Sign up to request clarification or add additional context in comments.

1 Comment

Yes I had forgotten to create the 'test' folder under modules. Silly mistake by me.. anyway thanks for your feedback!
2

HMVC Modules folder for Codeigniter 3 How to implement HMVC in codeigniter 3.0?

codeigniter 3 hmvc tree reqire files I tested works

Comments

0

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"; 

5 Comments

you do not need to set modules path in config
make sure you set your routes also example in my answer
I believe that the documentation says that you need to set the modules path inside config.php
I have also set the routing like this but still no luck
This routing you said is used if you want to create admin pages/controllers. This Test controller is a simple testing one.. however I have set up my routing like this but still doesn't work
0

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.

Comments

0

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:

  1. This I am not 100% sure, but if I remember correctly I could not see subfolders so I had to chmod 755 on them again
  2. This was the killer: my file name was with lowercase ("welcome.php" instead of "Welcome.php") for the controller. Once I renamed the file with uppercase I got rid of 404 and everything worked.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.