Currently, I am working on restructuring an existing code base. I’m new to php frameworks, but I do know in general how MVC works.
Right now, there is one controller file, one model file, and thirty view files.
Should every model correspond to a table?
Should every view correspond to an html page?
What about the controller? How can I break this thousand line monster into more organized code.
Thanks.
No. A model is often constructed from data from multiple sources. Don’t think in terms of tying it to your physical database structure even though there will probably end up being lots of similarity.
Not to sound trite, but every view should correspond to a view. I’m not sure exactly what you mean by a “page”.
Perhaps an example would be useful. Imagine a user registration page. The model is User and might contain fields such as:
Now, that data may be in multiple tables. For example: Party, Person, Contact and Address.
There will probably be several views:
Typically all of this will be handled by a single controller as all the processes are inter-related.