MY_Controller problems. - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: MY_Controller problems. (/showthread.php?tid=28600) |
MY_Controller problems. - El Forum - 03-16-2010 [eluser]Unknown[/eluser] Hello, I was searching on forums, but don't have any idea what is wrong, I'm more than sure I did everything ok, but when try to extend MY_Controller I got error that class is not found. Here's how it looks like. /application/libraries/MY_Controller.php: Code: <?php if (!defined('BASEPATH')) exit('No direct access allowed.'); /application/controllers/welcome.php: Code: class Welcome extends MY_Controller { Result? Fatal error: Class 'MY_Controller' not found in welcome.php, line 3. I'm on PHP5. Have no idea what it's not working. Any tips? Regards MY_Controller problems. - El Forum - 03-16-2010 [eluser]mohsin917[/eluser] I don't know the solution but is this sure that you can not extend a controller class to a library. /application/libraries/MY_Controller.php MY_Controller problems. - El Forum - 03-16-2010 [eluser]Unknown[/eluser] [quote author="mohsin917" date="1268763907"]I don't know the solution but is this sure that you can not extend a controller class to a library. /application/libraries/MY_Controller.php[/quote] Eee...sorry? This is the way of extending core Controller so I don't know what are you talking about. MY_Controller.php file should be placed into library folder. MY_Controller problems. - El Forum - 03-16-2010 [eluser]mohsin917[/eluser] Sorry I didn't now that.. MY_Controller problems. - El Forum - 03-16-2010 [eluser]n0xie[/eluser] Try: Code: class MY_Controller extends Controller MY_Controller problems. - El Forum - 03-16-2010 [eluser]danmontgomery[/eluser] It needs to be parent::Controller(), not parent::__construct(). __construct doesn't exist in CI core classes, since it's a PHP 5 method... Not sure if that will solve the class not being loaded, but it will be an issue nonetheless. Code: <?php if (!defined('BASEPATH')) exit('No direct access allowed.'); |