[eluser]Mirage[/eluser]
[quote author="jleequeen" date="1217643818"]@Eric Cope
For instance, I might have a user controller that handles things like add, edit, delete users. It seems to me that these actions logically fit inside of a user controller. But when it comes to say, logging in a user, does that go into user/login...or does that need to be a login controller all it's own.
[/quote]
Excellent example of your condundrum.
1. I'd say it's logically unlikely that authentication requests would be handled by a controller that also handles administration (probably protected) requests for managing users
2. A separate auth controller would make most sense to me. What it allows you to do is invoke your login from any section of your site.
3. Keep in mind that your controller need not represent the actual url. You have the power of the router to re-map requests to any given controller/method.
4. The best way to keep your controllers light is to use them for what their name suggests: controlling the flow of the request, cleaning input, handing off processing to models and libraries and invoking an appropriate view for output.
5. Put repeatable tasks into libraries, utility functions into helpers and do the heavy lifting in the models to keep your controllers light.
6. Models are often mis-construed as an abstraction of the database layer. This is wrong IMO. The abstraction of the database is the Database library. It's just that Models - representing the business end of your app/site - most often connect to databases in the process. Models are the right place to errrm.... 'model' and transform the input regardless of whether it involves db access or not. Segment your models to match the backend process: users, content, blogs etc etc.
The beauty of CI is that you really don't have to follow any MVC strictness. You can refactor your code as it grows. In the end it doesn't make a difference whether you load a big controller or a big Model. Given today's hardware don't worry too much about performance implications of loading multiple small vs fewer big files. The tradeoffs are negligible in the greater scheme. What you should focus on instead is keeping your code manageable and readable by breaking it down it makes most sense to
you.
Cheers,
-m