问题描述
我正在使用MVC模式进行Web开发.我使用Codeigniter框架.我找到了 http://fuelphp.com/ and 和 http://kohanaframework.org/,他们正在使用HMVC.仍然不明确HMVC,为什么我们应该使用HMVC代替MVC?阅读HMVC模式后,我感到困惑,这与MVC并没有太大不同.您能解释一下为什么我们应该将HMVC用于Web应用程序开发?
推荐答案
层次模型 - 视图控制器(HMVC)模式是直接的 扩展到设法解决许多的MVC模式 已提到的可伸缩性问题. HMVC首先在 博客文章的标题为 客户层 2000年7月在Javaworld网站上. 文章集中于与图形用户一起使用HMVC的好处 接口.已经有一些建议作者 实际重新解释了另一种称为的模式 1987年描述的演示文稿-Abstraction-Control(PAC). 在Javaworld中,提供了有关HMVC如何帮助进来的详细说明 使用GUIS的桌面应用程序的设计.重点 文章是为了证明如何使用HMVC来创建可扩展的Web 申请.
HMVC是传统的MVC三合会的集合 应用.每个三合会都是完全独立的,可以执行 没有其他任何.对三合会提出的所有请求必须 使用控制器接口,永不加载模型或库 在自己的领域之外.三合会内的物理位置 托管环境并不重要,只要可以从 系统的所有其他部分. HMVC的独特功能 鼓励现有代码的重复使用,简化了不同的测试 系统的一部分并确保应用程序很容易 增强或扩展.
来自用HMVC缩放Web应用程序 由Sam de Freyssinet
其他推荐答案
HMVC可以执行MVC可以做的任何事情,并且更多
您将在MVC中遇到或遇到的一件事是,您无法从另一个控制器调用控制器(除非您使用自定义库或助手来执行此操作)
在HMVC(层次模型视图控制器)中,您可以做到这一点,我将总结此处的所有素质:
- 在其他项目中重复使用您的代码
- 简化维护您的项目
- 扩展您的项目
- 组织代码
- 模块化结构
尝试HMVC后,您永远不会回到MVC 这是一张更清晰的图片
用于CodeIgniter使用"模块化扩展-HMVC"
模块化扩展使Codeigniter PHP框架模块化.模块是独立组件的组, 通常在应用程序模块子目录中安排的模型,控制器和视图,可以将其放入其他Codeigniter应用程序中.
模块控制器可以用作普通控制器或HMVC控制器,它们可以用作小部件,以帮助您构建查看部分.
如果要将CodeIgniter与HMVC模式一起使用,则可以使用模块化扩展名-HMVC
这里有一些不错且有趣的视频教程,可以在Codeigniter中与HMCV一起使用Rails
list = plbepr3pmwcawdz6fgnyoyvicez4hrjpec时间plbepr3pmwcawdz6fgnyoyvicez4hrjpec&index = 1
希望有帮助!
问题描述
I'm using MVC pattern for web development. I use codeIgniter framework. I found http://fuelphp.com/ and http://kohanaframework.org/ , they are using HMVC. It still not is clear of HMVC and why we should use HMVC instead of MVC ? I am confused after reading HMVC pattern and it's not too much different from MVC. Can you explain why we should use HMVC for web application development ?
推荐答案
The Hierarchical-Model-View-Controller (HMVC) pattern is a direct extension to the MVC pattern that manages to solve many of the scalability issues already mentioned. HMVC was first described in a blog post entitled HMVC: The layered pattern for developing strong client tiers on the JavaWorld web site in July 2000. Much of the article concentrates on the benefits of using HMVC with graphical user interfaces. There has been some suggestion that the authors where actually re-interpreting another pattern called Presentation-Abstraction-Control (PAC) described in 1987. The article in JavaWorld provides a detailed explanation of how HMVC can aid in the design of desktop applications with GUIs. The focus of this article is to demonstrate how HMVC can be used to create scalable web applications.
HMVC is a collection of traditional MVC triads operating as one application. Each triad is completely independent and can execute without the presence of any other. All requests made to triads must use the controller interface, never loading models or libraries outside of their own domain. The triads physical location within the hosting environment is not important, as long as it is accessible from all other parts of the system. The distinct features of HMVC encourages the reuse of existing code, simplifies testing of disparate parts of the system and ensures that the application is easily enhanced or extended.
From Scaling Web Applications with HMVC by Sam de Freyssinet
其他推荐答案
HMVC can do anything that MVC can and more
one of the things that you will or had struggled with in MVC is that you can't call a controller from another controller (unless you use a custom library or helper to do that)
in HMVC (Hierarchical Model View Controller) you can do that , i would sum all the qualities in here:
- reuse your code in other projects
- simplify maintaining your project
- scale your project
- organize code
- modular structure
you will never go back to MVC after trying HMVC here is a picture to be more clear
for CodeIgniter use "Modular Extensions - HMVC"
Modular Extensions makes the CodeIgniter PHP framework modular. Modules are groups of independent components, typically model, controller and view, arranged in an application modules sub-directory that can be dropped into other CodeIgniter applications.
Module Controllers can be used as normal Controllers or HMVC Controllers and they can be used as widgets to help you build view partials.
if you want to use codeigniter with HMVC pattern, you can use Modular Extensions - HMVC here
https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc
and here are some nice and funny video tutorials that will get you on rails with HMCV in codeigniter
https://www.youtube.com/watch?v=8fy8E_C5_qQ&list=PLBEpR3pmwCawDZ6FgNYoyvicEz4HrJPec&index=1
hope that helps!