Controller file and class names... - 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: Controller file and class names... (/showthread.php?tid=56684) |
Controller file and class names... - El Forum - 01-11-2013 [eluser]xerobytez[/eluser] This is an issue with CI that has bugged me for quite some time. So I've written a library named settings that manages my applications settings in the database. Now in my admin panel I'd logically like to have a controller named settings where the user can easily change my apps settings. Due to CI's goofy naming conventions I can't have a library and a controller named settings as it creates a collision due to them having the same class name. In a perfect world it would be great if CI had standardized naming conventions for example, model and helper filenames end with _model and _helper respectively. Why don't controllers? or libraries? Has anyone encountered this issue and come up with a solution? Maybe a modified codeigniter and\or router class in the core? Thanks for reading Controller file and class names... - El Forum - 01-11-2013 [eluser]Prullenbak[/eluser] I don't think you're not allowed to name your controller Settings_controller. Afterwards you can change your routes file to map 'settings/whatever' to 'settings_controller/whatever'. I agree, this is a bit of a hassle, but it should work. In your specific case, why not call it prefs or admin or whatever? Controller file and class names... - El Forum - 01-11-2013 [eluser]xerobytez[/eluser] This case was just an example, I've encountered it many times in the past with different scenarios. Excellent idea with the routes though I didn't think of that, I ended up using the code below and all is working well. Thanks for the idea! Code: $route['(:any)'] = '$1_controller'; |