Simple MVP example with PHP

自闭症网瘾萝莉.ら 提交于 2019-11-30 15:32:35
tereško

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.

Will Sams

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?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!