Welcome Guest, Not a member yet? Register   Sign In
HMVC: problem when controller extends from MX_Controller
#1

[eluser]Unknown[/eluser]
Hello,

The problem is when my controller extends from 'MX_Controller', php thows an error message like ' Fatal error: Cannot redeclare class CI in application\third_party\MX\Base.php on line 83'

My code is :
Code:
class Javascript extends MX_Controller {

    function javascript()
    {
        parent::__construct();
    }

    function index()
    {
    }

    function add() {

    }


    function _remap() {

    }
}

But, my code's working when the controller extends only from Controller.

Why?

Patrice
#2

[eluser]bl00dshooter[/eluser]
http://philsturgeon.co.uk/index.php/news...ing-it-DRY
#3

[eluser]Unknown[/eluser]
My problem concern Modular Extensions - HMVC.

MX_Controller is an controller for Modular Extensions - HMVC, and when one of my controller extends from it, PHP throw the error : Fatal error: Cannot redeclare class CI in application\third_party\MX\Base.php on line 83
because in the 'third_party/MX/Base.php'.

I have monitoring the tutorial page on HMVC at the url https://bitbucket.org/wiredesignz/codeig.../wiki/Home .

Patrice
#4

[eluser]Andrewgwood[/eluser]
Your controller should extend MY_Controller not MX by default. You need to either change the prefix in config/config.php from MY_ to MX_ or in libraries/my_controller.php add a definition for class MY_controller extends MX_Controller since the mx controller is loaded into that file

Hope that helps
#5

[eluser]Unknown[/eluser]
if you want admin_controller to extends MX_controller, you should have a Admin_controller class in library folder.

<?php (defined('BASEPATH')) OR exit('No direct script access allowed');

class Admin_Controller extends MX_Controller {


function __construct()
{
parent::__construct();


}

}



then any controller can extends Admin_Controller.
#6

[eluser]InsiteFX[/eluser]
1) State what version of CodeIgniter you are using!

CI 2.0 place in application/core - CI 1.7.x place in application/libraries
Code:
class MY_Controller extends MX_Controller {

    public function MY_Controller()
    {
        parent::MX_Controller();

    }
}

// For Modular Separation Controllers
class MY_Controller extends CI_Controller {

    public function __construct()
    {
        parent::__construct();

    }
}


class Admin_Controller extends MY_Controller {

    public function __construct()
    {
        parent::__construct();

    }
}

class Public_Controller extends MY_Controller {

    public function __construct()
    {
        parent::__construct();
    }
}
Extend your other controllers from either Admin_Controller or Public_Controller.
All other Controllers go into application/controllers.

InsiteFX
#7

[eluser]wiredesignz[/eluser]
@sportif, Read the Modular Extensions HMVC Bitbucket wiki regarding constructors.




Theme © iAndrew 2016 - Forum software by © MyBB