MY_Controller vs. Foo_Controller - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: MY_Controller vs. Foo_Controller (/showthread.php?tid=33305) |
MY_Controller vs. Foo_Controller - El Forum - 08-21-2010 [eluser]pbarney[/eluser] What is the functional difference between: Code: class MY_Controller extends Controller ...and... Code: class LoginRequired_Controller extends Controller They're both extending "Controller", so what's the point of using MY_? Thanks for any insight! Peter MY_Controller vs. Foo_Controller - El Forum - 08-21-2010 [eluser]J Maxwell[/eluser] CodeIgniter will automatically look for and load "MY_", although if you change the setting in the config file then you can get it to load "LoginRequired_" automatically instead? Although then all of your custom overrides to core libraries would have to be "LoginRequired". If MY_ is bothering you, why not change it to "Site_" or "Wizard_" or something equally cool? Ahem. MY_Controller vs. Foo_Controller - El Forum - 08-21-2010 [eluser]pbarney[/eluser] Ah, you've cleared it up. It's that "MY_" is autoloaded whereas the other is not. I don't have a problem with the prefix; I just didn't understand it's purpose. Thanks! MY_Controller vs. Foo_Controller - El Forum - 08-21-2010 [eluser]J Maxwell[/eluser] Hehe I did have a problem with the prefix, just sounded a little unprofessional in code that sometimes the client would see, so changed it to my company initials. Glad to help, John MY_Controller vs. Foo_Controller - El Forum - 08-21-2010 [eluser]pbarney[/eluser] So a way around all this (if you don't mind PHP 5 compatibility) is to add an auto-load function to config.php: Code: /* Thanks to Phil Sturgeon, for this bit of usefulness. |