I have developed my own framework which I consider to be good and it is in production for several of my web apps. It's fully OOP but it's not fully MVC and I don't like that, so I branched it to try to make it to a full MVC and also make it be programmer-friendly as possible. And I got to some problems and I have some questions, with how should I brake down my framework logic. That why I need your expert advice.
My main question is with how to handle form submitting/correcting/reloading. But before I get into that let's see if I got the whole concept right.
This my the order of the classes the handle a request:
1. Bootstrap
2. Router
3. Controller
4. Model
5. View
If I understand correctly, firstly the Bootstrap will receive the request and spawn a router that will dispatch it accordingly to the appropriate Controller.
Is this Correct?
Then the Controller responsible will process the request (GET or POST) and figure out what to do with it and which Action to call. The Actions (class methods) reside within the Controller.
e.g.
Code: Select all
Controller->ActionAddItemForm();
Through these Actions (methods) the Controller will spawn the appropriate Models and call some of their methods (e.g. ModelItems->AddNewItem(); ). When this action finishes, then the Controller spawns and calls the View to render the output.
Correct? Or should the Model call the View for rendering? What MVC dictates here?
The View must have different methods for displaying different things? Like for instance an html table, or a div with the contents of the Model?
e.g.
Code: Select all
View->compileHTMLTable(); and in the end View->RenderWholeHTMLPage();
Code: Select all
$HTMLTable = Model->compileHTMLTable();
View->Add($HTMLTable);
View->RenderHTMLPage();
The above problems are more profound when I deal with Forms. In particular, I can't figure out which object is responsible for building up the form and it's fields, which one should process the POSTed variables and attach them to according fields, which one should validated them, and which one will act upon sucessfully or unsuccefull submission.
The MVC examples I find googling about, they are almost useless because most of them have seriously gotten wrong the whole paradigm.
Thanks in advance!