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

后端 未结 11 757
野趣味
野趣味 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条回答
  •  独厮守ぢ
    2021-02-01 10:32

    Where I am having the most problem is deciding when to actually create a controller vs making something just an action because it's not always so clear cut.

    Wherever possible, use one controller per view. That way:

    1. you are not loading more code than is necessary per request
    2. there is a clear 1:1 link between controller and view (especially if they share the same name).

提交回复
热议问题