I know how to work with the MVC model, but I don't have an idea how to work with MVP. I read about the differences between them but don't know how to accomplish it.
Asked
Active
Viewed 1.3k times
4
-
1Please have a look here: http://stackoverflow.com/questions/2056/what-are-mvp-and-mvc-and-what-is-the-difference – lkaradashkov Jun 05 '12 at 15:59
-
1Yes, but there is no example. Just a simple code. – grape1 Jun 05 '12 at 16:01
2 Answers
4
The difference is twofold:
- view is passive and unaware of model
- presenter (controller) changes state of model, reads information and passes it to view
public function showUsers()
{
// -- snip
$data = $accountManager->getUserDetails($from = 10, $to = 20);
$view->bind('list', $data);
// -- snip
}
This would be a simplified example of presenter's method. Here is an old answer, briefly explaining the differences between MVC-like patterns used in php.
0
The MVP pattern is commonly used in event-driven development and evidently there are some PHP frameworks which supports this paradigm. Here is another Stackoverflow question from a couple of years ago that may help get you pointed in the right direction:
-
2MVP has nothing to do with event-driven paradigm. Here are few example of MVP frameworks, you might have heard of: Ruby on Rails, CodeIgniter, CakePHP, Yii. – tereško Jun 09 '12 at 11:44
-
The MVP pattern is "commonly" used with the event driven paradigm as it fits there. Do I have your blessing now, Dr. tereško? – Will Sams Jun 11 '12 at 10:59
-
1MVP is commonly (mis)used. Period. And since PHP was in the question tags, event driven paradigm does not really apply .. unless you see web sites themselves as inherently event driven applications. – tereško Jun 11 '12 at 11:31
-
1