In Asp.NET applications, there is a service layer that stands between the repositories and the controllers, so that different parts of the application can make use of the same logic, without any inconsistencies when one part changes.
For example, in CodeIgniter, if there is a part of the application that responds to REST API calls, I’d need to implement the same logic used in the Account controller for authentication. If there were something like UserService, that could be so easy.
What I’m asking is, do you think that this approach makes sense with CodeIgniter, if there is already a built functionality that covers that and if not, what would be the best way? Should I use libraries create my libraries which act like a service layer? Should I just put everything into models (probably not)? Or, wouldn’t CodeIgniter be suited for apps which require that kind of complexity at all?
I need your insight on this. Thanks for the help.
CodeIgniter can handle this perfectly. The idea is that the Controller is the main part of a request where logic is handled right? So a user hits a URL, they go to a controller and the controller decides wether to show them data, redirect them somewhere or tell them to shove off.
To share logic throughout your application you can create a MY_Controller (extending the main CI_Controller class) then this will be run for every controller. If you want to be more specific and have different kinds of controller loading different base controllers then you can.
http://philsturgeon.co.uk/news/2010/02/CodeIgniter-Base-Classes-Keeping-it-DRY