Rather a basic question, though i’m a bit confused with the architecture.
I am programming a website using Yii framework.
There is a SiteController and AdminController (built not by me).
All the site administration is in AdminController, and the user interaction in SiteController.
I know it is not correct as it is not model-based.
Now, I want to implement user registration. The user can signup and administrator can change his properties.
Is it better to build UserController or manage all the above in the existing controller (not breaking previous logic)?
By MVC standards its best to split controllers by function groups.
Auth Controller
handles authentication/registration/deletion. Sets session vars for logins which all other controllers check first thing.
Admin Controller
handles all administrative tasks
User Controller
handles all user tasks. Maybe editing profiles, or posting to a personal blog?
Front Controller
handles all public facing tasks, displaying non auth based pages etc.
Unrelated, CodeIgniter Example
I use this methodology in my CI projects. This information will vary from Yii framework but it gives you a glimpse of a proper MVC setup.
I have core controllers such as:
application/core/FRONT_Controller.phpthis controller extends CI_Controller and handles all the setup of my pub facing pages. All of my public facing controllers extend FRONT_Controller instead of CI_Controller.
application/core/USER_Controller.phpthis controller handles all of my users authentication.
application/core/ADMIN_Controller.phpthis controller does preliminary checks, again all of my admin based controllers extend this controller so the authentication fires off right away… IE:
application/controllers/blog.php: