当使用模块在Zend框架? [英] When to use Modules in Zend Framework?

查看:120
本文介绍了当使用模块在Zend框架?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在设立新的项目ZF我normaly有这样的目录结构:


  • 申请

    • 模块

      • 默认

        • 控制器

        • 表格

        • 查看

        • 模式


      • 管理

        • 控制器

        • 表格

        • 查看

        • 模式



    • 语言

    • 共享

      • 模式




  • 公共

我只用在例如布局不同势,或不同势数据库时,当然还是模块时它的一个非常特殊的情况下,像一个管理员后端或论坛/板。然后,我有控制器应用程序的不同部分。例如JobController,ProductController的等等。

我的一个同事给我看了他的基地布局。它几乎是相同的,但他使用了大量的模块。像求职模块,产品模块的每个模块的这个大都有2控制器的索引控制器和AdminController。

他的作品的设置和心不是错的,但我从来没有见过这样的做法,其似乎不需要复杂的。

所以要告一段落:


  1. 当你使用的模块,当你将坚持
    控制器?

  2. 请告诉我您的规则来决定模块或不模块?

  3. 什么是您点的缺点和我的同事的安装程序的利弊
    的看法?

  4. 什么是你的观点的利弊和我设置的利弊?

TIA

Rufinus

修改:看<一个href=\"http://mwop.net/blog/2012-04-30-why-modules.html\">http://mwop.net/blog/2012-04-30-why-modules.html在ZF2.0上重新设计的模块信息


解决方案

  

什么是的利弊和在你的观点我同事的设置的利弊?


更好的可重用性。假设你的同事不停地从其他模块上独立的模块里面的code,他创造有效的一个自包含的问题域。不像你的方法,他可以更容易地在整个模块复制过来,然后其他应用程序。

When setting up new ZF Projects i normaly have this directory structure:

  • application
    • modules
      • default
        • controller
        • forms
        • view
        • models
      • admin
        • controller
        • forms
        • view
        • models
    • language
    • shared
      • models
  • library
  • public

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.

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.

So to come to an end:

  1. When would you use Modules and when you would stick to Controllers?
  2. Whats your rule to decide Module or not Module ?
  3. What are the cons AND pros of my colleague's setup in your point of view?
  4. What are the cons AND pros of my setup in your point of view?

TIA

Rufinus

EDIT: see http://mwop.net/blog/2012-04-30-why-modules.html for info on the redesigned modules in ZF2.0

解决方案

What are the cons AND pros of my colleague's setup in your point of view?

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆