何时在 Zend 框架中使用模块? [英] When to use Modules in Zend Framework?
问题描述
在设置新的 ZF 项目时,我通常具有以下目录结构:
When setting up new ZF Projects i normaly have this directory structure:
- 申请
- 模块
- 默认
- 控制器
- 表格
- 查看
- 模型
- 控制器
- 表格
- 查看
- 模型
- 模型
我只在布局不同时使用模块,或者使用不同的数据库,或者当然当它是一个非常特殊的情况,比如管理后端或论坛/板.然后我有控制器用于应用程序的不同部分.例如 JobController、ProductController 等.
I use only modules when e.g the layout is diffrent, or a diffrent database is used, or of course when its a very special case like a admin-backend or a forum/board. Then i have Controller for the different parts of the application. e.g JobController, ProductController and so on.
我的一位同事向我展示了他的基本布局.它几乎相同,但他使用了很多模块.像 Job-Module、Product-Module 一样,这些模块中的每一个都有 2 个控制器,一个是 IndexController 和一个 AdminController.
A colleague of mine showed me his base layout. its nearly the same, but he uses a lot of modules. like Job-Module, Product-Module each of this modules mostly have 2 Controllers an IndexController and an AdminController.
他的设置有效并且没有错,但我从未见过这样的方法,它似乎不需要复杂.
His setup works and isnt wrong, but i never saw such an approach, its seems unneeded complicated.
到此结束:
- 你什么时候会使用模块,什么时候你会坚持使用控制器?
- 您决定模块与否的规则是什么?
- 在你的观点中,我同事的设置有哪些优缺点
- 在您看来,我的设置有哪些优缺点?
TIA
鲁菲纳斯
编辑:见http://mwop.net/blog/2012-04-30-why-modules.html 有关 ZF2.0 中重新设计的模块的信息
EDIT: see http://mwop.net/blog/2012-04-30-why-modules.html for info on the redesigned modules in ZF2.0
推荐答案
在您看来,我同事的设置的
缺点和优点是什么?更好的可重用性.假设您的同事将模块内的代码与其他模块无关,他有效地创建了一个自包含的问题域.与您的方法不同,他可以更轻松地将整个模块复制到其他应用程序中.
Better Reusability. Assuming your colleague kept the code inside the modules indepedent from other modules, he effectively created a self-contained problem domain. Unlike with your approach, he can more easily copy the entire module over to other applications then.
这篇关于何时在 Zend 框架中使用模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
- 默认
- 模块