[eluser]Wayne Smallman[/eluser]
Hi guys!
I'm having
the exact same problem outlined in an earlier thread. However, the supposed fix doesn't fix anything, as I'm using a version much newer than the one recommended in the thread.
I have:
Code:
// controller start.php
class Start extends MY_Controller {
function __construct() {
parent::__construct();
} // end function __construct()
...
Code:
// class MY_Controller.php
class MY_Controller extends CI_Controller {
function __construct () {
parent::__construct();
} // end function __construct()
...
All of which gives me an error:
Code:
Fatal error: Class 'MY_Controller' not found in /path/controllers/start.php on line 3
MY_Controller is in the application/libraries folder.
Any ideas?
[eluser]TWP Marketing[/eluser]
Try putting your controllers in the controller directory, not the libraries dir?
[eluser]victorche[/eluser]
MY_Controller.php must be in application/core
not in application/libraries or application/controllers
[eluser]TWP Marketing[/eluser]
My bad, you are correct.
The path may be the problem then.
The error message is not specific as to the the content of the path var. Where does it point?
[eluser]Wayne Smallman[/eluser]
Hi guys!
Start is a controller, and as such is in the controller folder. MY_Controller is a library, and as such is in the library folder.
This is the exact same layout as a previous project using 1.7.x, which is working perfectly fine.
I've just placed MY_Controller.php in application/core and it's made zero difference.
[eluser]InsiteFX[/eluser]
This works for me!
Place all 3 files in application/core
Code:
class MY_Controller extends CI_Controller {
// --------------------------------------------------------------------
/**
* Class Constructor
*
* @access public
* @return void
*/
public function __construct()
{
parent::__construct();
}
}
class Admin_Controller extends MY_Controller {
// --------------------------------------------------------------------
/**
* Constructor
*
* @access public
* @return void
*/
public function __construct()
{
parent::__construct();
}
}
class Public_Controller extends MY_Controller {
// --------------------------------------------------------------------
/**
* Class Constructor
*
* @access public
* @return void
*/
public function __construct()
{
parent::__construct();
}
}
Now extend all your other controllers for either Admin_Controller or Public_Controller
All new extended Controllers should go into application/controllers.
InsiteFX
[eluser]Wayne Smallman[/eluser]
InsiteFX, that's working now, thanks.
Q. why does MY_Controller have to be placed in the application/core directory?
[eluser]Basketcasesoftware[/eluser]
Because it's extending a CI core function.
[eluser]InsiteFX[/eluser]
Any Class that is in th systen/core directory that is extened has to be placed into the application/core directory. These are Core Classes.
MY_Controller is extending the system/core/CI_Controller, as you can see this is a Core Class.
Any Class that is extended that is in the system/libraries directory has to be placed into the application/libraries directory. These are Library Classes.
InsiteFX
[eluser]Basketcasesoftware[/eluser]
Thanks for clarifying my own response better, InsiteFX.
