I want to build an admin panel for my small application, what approach should I use?
- Should I write another admin controller in the application controllers folder?
- Or should I follow some other approach which is good for big projects too?
I want to build an admin panel for my small application, what approach should I use?
Having another controller is fine -- I usually create a base admin controller Admin_Controller
extending CI_Controller
, and then all my admin-related controllers extends that base admin controller.
If you're already using the MVC architecture then it makes sense to stick with it, doesn't it? I see no reason why the administration actions of your 'admin panel' can't fit into it.
However, I would say that an "admin controller" sounds like a great deal of responsibility for one controller! Ideally I would argue that your controllers should be nice and thin, with few responsibilities. It's hard to say without knowing what you're working with though, I'd definitely look at what your admin panel will contain and split out the responsibilities into a number of categories, actions, responsibilities, or something; creating an admin area containing several of these controllers. Perhaps they could all extend a base AdminController class?