Recently I stumbled across different MVC pattern which confuses me.
I would like to know which does actually fit the most to the MVC architecture.
$model = new Model($request); // get data (by routing and url)
$controller = new Controller($model); // pass data for later manipulation
$view = new View($model); // load template (dynamically)
$controller->action(); // update model data (user action)
echo $view->output(); // assign data and output rendered template
In the above example, the controller seems to be obsolete and optionally used if there is no user interaction.
class Controller{
$model = new Model($request); // get data
$view = new View($model); // load template
}
$controller = new Controller($request);
echo $controller->output();
In this example, the controller is rather used to wrap the model and the view. The user action would already be included in the request string and not separated like in the previous example. Furthermore the controller is responsible for the rendered output and not the view.
$model = new Model($request); // get data
$view = new View($template); // load template
$controller = new Controller();
echo $controller->output($view, $model);
Similar to the previous, the controller is responsible to connect model and view. The template is statically assigned to the view.
thx!