Zend Framework 1.10 中自定义函数的放置位置 [英] Where to put custom functions in Zend Framework 1.10

查看:22
本文介绍了Zend Framework 1.10 中自定义函数的放置位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须在基于 Zend Framework 1.10 的 Web 应用程序中使用自定义函数/对象.把它们放在哪里最好?

I have to use custom functions / objects in my web application based on Zend Framework 1.10. Where is the best place to put them ?

提前致谢

推荐答案

你描述的对象属于模型,所以它们进入application/models.请记住,模型是与表示层无关的一切(例如 MVC 中的 V 和 C).我的建议是采用这种结构:

The objects you describe belong to the Model, so they go in application/models. Remember that the Model is everything that is not pertaining to the presentation layer (e.g. the V and C in MVC). My suggestion would be to have this structure then:

application
- models
-- my            -> to indicate this is yours
--- persistence  -> contains all classes that capsulte Data access logic
--- domain       -> business objects in your domain of application
--- service      -> services that use the domain objects or the persistence layer
--- mappers      -> your ORM layer (unless you are not using Doctrine anyway)

如果您有足够通用的类可以在其他应用程序中重用,您可以将它们放在/lib 文件夹中.但是,为您的应用专门制作的所有内容都应包含在模型中.

If you have classes that are generic enough to be reused in other applications, you can place them into the /lib folder. But everything specifically made for your app should go in models.

此外,请查看 Padraic Brady 的 ZFPlanet 示例项目

Also, have a look at the ZFPlanet Sample Project by Padraic Brady

这篇关于Zend Framework 1.10 中自定义函数的放置位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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