4

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.

hakre
  • 193,403
  • 52
  • 435
  • 836
grape1
  • 759
  • 2
  • 8
  • 19

2 Answers2

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.

Community
  • 1
  • 1
tereško
  • 58,060
  • 25
  • 98
  • 150
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:

Does PHP supports MVP pattern?

Community
  • 1
  • 1
Will Sams
  • 196
  • 2
  • 14
  • 2
    MVP 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
  • 1
    MVP 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
    And this is what has become of Stackoverflow. Have a good day, bro. – Will Sams Jun 11 '12 at 20:48