douzhan8303 2011-07-15 09:11
浏览 90
已采纳

打包通用zend模块的最佳方法

As our company starts using Zend Framework as the base framework for most of our projects, we want to share some common elements across all our projects. I talk about things like:

  • An implementation of a model (based on doctrine2)
  • RBAC for the model, including user, group, role models
  • A xml-based templating engine for ajax backend interfaces
  • (you name it) ...

Basically, all things to put "zend on rails" and get going. What is the best way to package these components? I see two possibilities:

As modules

We include the necessary functions as separate modules into the modules folder.

Pro:

  • We can set routes and execute code, which is good for many modules (imaginary example: a paypal module needs some kind of callback url. If our module can set it up on its own, no configuration from the "project developer" is needed).
  • We can provide real functionality (like the user administration) out of the box
  • We have a bootstrap to set up autoloading and doctrine etc.

Con:

  • Bad place? Interferes with the users project
  • A little harder to share between projects (git submodules instead of classpath)

In the library folder

We put it in the library folder and point the classpath to it.

Pro:

  • Clean solution
  • Sharing across projects

Con:

  • Bootstrap has to be explicitly called
  • No direct routing or actions - everything has to be proxied through the concrete project

So, how do you solve this? Where do you put your reusable, general purpose stuff in zf?

  • 写回答

1条回答 默认 最新

  • duanhuan7750 2011-07-15 10:41
    关注

    I think you should use both approaches.

    When developing "library-like" code, as in kind of "infrastructure" classes and other things that are reusable (like ZF's own components, Doctrine 2's components etc.), you can put them into the library directory. (or its own entirely separate project)

    When developing actual ZF modules (like an auth module for example), then format the code around the ZF module structure.

    I think by using this kind of approach you get all the benfits you listed, and pretty much none of the cons :)

    As one additional idea, if you develop your architecture parts as "services", you could even keep them running as their own web service endpoints.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 fluent里模拟降膜反应的UDF编写
  • ¥15 MYSQL 多表拼接link
  • ¥15 关于某款2.13寸墨水屏的问题
  • ¥15 obsidian的中文层级自动编号
  • ¥15 同一个网口一个电脑连接有网,另一个电脑连接没网
  • ¥15 神经网络模型一直不能上GPU
  • ¥15 pyqt怎么把滑块和输入框相互绑定,求解决!
  • ¥20 wpf datagrid单元闪烁效果失灵
  • ¥15 券商软件上市公司信息获取问题
  • ¥100 ensp启动设备蓝屏,代码clock_watchdog_timeout