I have implemented Codeigniter HMVC which works fine. Then I'm extending MX_Controller
with MY_Controller
to share functionality and properties between all my modules and to keep my code DRY.
But I noticed that while extending MY_Controller
from MX_Controller
I can no longer access the public properties from MY_Controller
on any of the extended child classes.
Some sample code:
class MY_Controller extends MX_Controller {
public $variable;
function __contruct()
{
parent::__contruct();
$this->variable = 'Foo';
}
}
Then on any controller which I extend from MY_Controller:
class Foo extends MY_Controller {
function __construct()
{
parent::__construct();
}
function someFunction()
{
var_dump($this->variable);
}
}
When I trying to access the public property $variable
in any child controller I get Null
or empty string.
I have searched high and low for this with no luck, my only guess is an issue with HMVC MX_Controller
. Any Ideas?
After hours of checking, it was a simple mistake on my behalf. I had misspelled the name parent::__contruct on MY_Controller, it should be parent:__construct.