Models & Controllers!

Hello guys!

The controller and model can have different names? What i mean is, i created a UserController that going take the actions about the login, register, logout, activation and password recovery for user, so at this point i got UserController.php and User.php (model). If im not wrong, when we create the CRUD operations on Gii, the model (User.php) and controller (UserController.php) has the same name.

Ok, until here everything is alright…but after the user has done the login, the app goes redirect him to the account section.

In this part my idea is to have a AccountController.php (for actions like profile, alerts, messages, etc…) and the respective models, i.e. Profile.php, Messages.php, Alerts.php and so on… where some of this models, come from the database tables.

I’m going to use 3,4 or more differents models, for 1 controller. What you guys think about this? Is it ok or im going in the wrong way about the MFC/DRY principles ?


It’s fine, i don’t see any problem with this.

You’ll have specialized models/controllers which is a good thing overall, allowing you to keep a clean codebase.