How do MVC components fit together?
model-view-controller, php
Solution
The Controller retrives data from the Model and passes it to the View
As you said it's verbose and messy. But that's the most appropriate solution with the philosophy of MVC.
The Controller passes the Model to the View
Seems valid too. However it'll require for the view to ask for some model method. Which is not really in the spirit of MVC. Your view should only render the datas that are provided to it, without caring about the context.
The Controller passes the View to the Model
Forget that one. Here it is messy.
Problem
I've seen a number of examples of ways MVC components fit together on the web. The Controller retrives data from the Model and passes it to the View This seems a bit verbose and messy. ``` $model = new Model; $view = new View; $view->set('foo', $model->getFoo()); $view->display(); ``` The Controller passes the Model to the View What if the View needs data from multiple Models? ``` $model = new Model; $view = new View($model); $view->display(); //View takes what is needed from the Model ``` The Controller passes the View to the Model ``` $view = new View; $model = new Model($view); $view->display(); //Model has told the View what is needed ``` Which of these is the "best" way to go about things? If none, what is?