How Do You Convert a Page-Based PHP Application to MVC?

后端 未结 11 756
野趣味
野趣味 2021-02-01 09:48

I\'ve been struggling for some time now with exactly how to recode a page-based PHP application using an MVC framework. Just for background, I am having to move the app into MVC

11条回答
  •  闹比i
    闹比i (楼主)
    2021-02-01 10:12

    The whole concept was made more clear to me by a series of three blog posts by Nemetral that explain the pattern as it evolves from a traditional Web page script and thus as the PHP logic becomes separate from the presentation logic, thus in terms of MVC, how a model becomes separate from the view . According to Nemetral:

    1. The first step is to move all PHP code that was up to now coupled with HTML tags, to the head of the page.
    2. The second step is to move all HTML tags to a separate file and access it via a PHP include. So when a request is made it is directed to the PHP code (controller and model) and this code then requests the HTML tags or presentation (view).

    I write more about this in my dissertation: http://kreus-cms.com/kreus/pages/written_work

提交回复
热议问题