2009-10-18 12:31
浏览 37


I've been getting to grips with MVC (in PHP) by way of Zend. My understanding of the Zend Framework is that each type of user request maps to a specific controller (which in turn may or may not map to a model), and each action maps to a view. I've noticed the same pattern in Codeigniter and Kohana, and to some extent also in Symfony. Effectively, the URL maps thus:

www.domain.com/index.php/CONTROLLER/ACTION/...additional parameters...

Is this always the case with MVC? In what way is this different from Page Controller as a design pattern?

图片转代码服务由CSDN问答提供 功能建议

我一直在通过Zend处理MVC(在PHP中)。 我对Zend框架的理解是每种类型的用户请求都映射到特定的控制器(而控制器可能映射到或不映射到模型),并且每个操作都映射到视图。 我在Codeigniter和Kohana中注意到了相同的模式,在某种程度上也在Symfony中。 因此,有效地,URL映射:

  www.domain.com/index.php/CONTROLLER/ACTION / ...其他参数... 
  <  / pre> 

MVC总是这样吗? 这与页面控制器的设计模式有何不同?

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

5条回答 默认 最新

  • duanbing6955 2009-10-18 13:39

    Zend Framework uses Two Step View. It's very similar to MVC. As you can see, theres not so much correspondence between the architecture and the url mapping.
    If you want to learn about likely architectures, read PoEAA by Martin Fowler.

    打赏 评论
  • douwei1174 2009-10-18 13:28

    I think the primary difference is that with the Page Controller pattern, you have a separate file for each page of your website. In a typical implementation of MVC in PHP, you can group common actions together in a single controller. Also, the typical MVC implementation in PHP support custom routing allowing you to create custom maps to controllers/actions without the need of using http server rewrites.

    打赏 评论
  • duannan3959 2009-10-18 20:04

    1-"Is this always the case with MVC?

    www.domain.com/index.php/CONTROLLER/ACTION/...additional parameters..."

    No its not always case you can extend the routing to be Domain based (as example ) :


    2-I think but I am not 100% sure that the page controller is subset of in MVC Pattern I mean Page Controller = the Controller ONLY !!!

    打赏 评论
  • dp0518 2009-10-18 20:10

    Yeah, it's the most common usage of uris. But there's noting saying that you can't use the MVC pattern with (ir)regular uris. A uri like http://www.domain.tld/?controller=home&action=posts or even http://www.google.com/search?hl=en&source=hp&q=MVC would do just fine.

    MVC is all about how you structure yourlayers and is not reflected in the uri.

    打赏 评论
  • donglongqiao9595 2010-07-03 13:38

    My answer here may be able to help you (or anyone else in this situation since this is set to Answered already).

    打赏 评论

相关推荐 更多相似问题