通俗地说Kohana 3.0的HMVC结构?
所以,我想我理解级联文件系统的基本术语,但我似乎无法理解 MVC 的“层次结构”。谁能告诉我使用 HMVC 相对于 MVC 的优势以及它的基本预期功能吗?
感谢您抽出时间!
So, I think i understand the cascading filesystem in it's basic terms, but I can't seem to wrap my head around the 'H'ierachy structure of the MVC. Could anyone tell me the advantages of using HMVC over MVC and it's basic intended functionality?
Thanks for your time!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
HMVC 更适合 Widget。例如,日历小部件可能有自己的控制器、模型和视图集,您可以简单地调用其控制器来从主页内部呈现特定视图以嵌入小部件。
重点是可重用的 GUI 元素。请参阅此处以获取更多阅读:http://www.javaworld.com/javaworld/jw-07-2000/jw-0721-hmvc.html" javaworld.com/javaworld/jw-07-2000/jw-0721-hmvc.html。
编辑:这是一个实际的以 PHP 为中心的链接: http ://techportal.inviqa.com/2010/02/22/scaling-web-applications-with-hmvc/。好像还有更好看的插图。
HMVC is better suited to Widgets. For example, a Calendar widget might have its own controller, models, and set of views, and you can simply call its controller to render a certain view from inside the main page to embed the widget.
The emphasis is on reusable GUI elements. See here for additional reading: http://www.javaworld.com/javaworld/jw-07-2000/jw-0721-hmvc.html.
Edit: Here's an actual PHP-centric link: http://techportal.inviqa.com/2010/02/22/scaling-web-applications-with-hmvc/. Seems to have nicer illustrations as well.
您可以在内部请求页面(控制器和操作由路由找到)。例如,您可以这样做:
并且
每个具有菜单的页面都不必执行所有逻辑来加载菜单等(例如从模型)。您只需向控制器发出请求,执行它并获得结果。正确使用时非常有用。
You can make a request for a page (controller and action is found by the routes) internal. You can do this for example:
and
Every page who haves a menu dont have to do all the logic to load the menu etc. (e.g. from models). You just make a request to the controller, execute it, and get the result. Very usefull when used correctly.
KO3 论坛上的人们描述了 HMVC 的能力,就像发出 AJAX 请求而无需额外的 HTTP 请求。
如果您想要构建一个将 API 作为应用程序的组成部分的系统,那么可能是一个现实世界的案例。以推特为例。使用 HMVC,您可以先编写 API,然后在应用程序中使用它。这可以节省代码重复或额外的 HTTP 请求。
但目前,这种方式的工作相当有限,主要是因为可以发送的请求类型。 这是我不久前发布的与此相关的论坛帖子。它可能会阐明 HMVC 如何发挥作用。
People on the KO3 forums have described the HMVC ability like making an AJAX Request without the extra HTTP Request.
A real world case maybe if you want to build a system that has an API as an integral part of the application. Twitter for example. With HMVC you could write the API first, and then use that within the application. This saves either code duplication or an extra HTTP Request.
At the moment though, working in this way is quite limited, mainly because of the type of requests that can be sent. Here is a forum post that I made a little while ago with regards to this. It may clarify how HMVC could be useful.