CodeIgniter Forums
Do I need to load My_ classes manually? - 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: Do I need to load My_ classes manually? (/showthread.php?tid=34795)



Do I need to load My_ classes manually? - El Forum - 10-09-2010

[eluser]sahanlak[/eluser]
I have a class named "My_admin" which extends the controller class, and its inside the library folder. I then extend this "My_admin" class and create other classes which are for an admin area. Anyway I couldn't get that far because I can't extend the "My_admin" class in other controllers. It throws an error saying..

Code:
Fatal error: Class 'My_admin' not found........

Do I need to load "My_admin" manually? I'm using a linux server and how should I named my classes? I'm asking this because when I migrate the application from windows to linux I got some file naming issues.

Thank you


Do I need to load My_ classes manually? - El Forum - 10-09-2010

[eluser]Jelmer[/eluser]
You'll need to either use an autoloader to load such a class (more on php.net) or just include it before the class decleration:
Code:
require APPPATH . 'libraries/My_admin.php';



Do I need to load My_ classes manually? - El Forum - 10-09-2010

[eluser]CroNiX[/eluser]
You only use the MY_ prefix when extending native CI things, like a library.

class MY_Form_validation extends CI_Form_validation

Then if the Form_validation library is autoloaded, it will autoload MY_Form_validation.

Its only for extending native CI classes though, not your own functions (unless those extend a native CI class)

http://ellislab.com/codeigniter/user-guide/general/creating_libraries.html