Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
287 views
in Technique[技术] by (71.8m points)

php - When to use Modules in Zend Framework?

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...