2010-07-16 33 views
2

我必須在基於Zend Framework 1.10的Web應用程序中使用自定義函數/對象。 最好的地方放在哪裏?將定製函數放在Zend Framework中的位置1.10

在此先感謝

+0

這取決於他們做什麼。你能告訴我們嗎? – Gordon 2010-07-16 10:34:12

+0

*(相關)* [Zend框架是否有修復版本的文件結構?](http://stackoverflow.com/questions/2536332/does-zend-framework-has-a-fix-version-of-file-結構/ 2536394)和[在哪裏把插件在Zend Framework網站](http://stackoverflow.com/questions/2400772/where-to-put-plugins-in-a-zend-framework-website/2400796) – Gordon 2010-07-16 10:37:06

+1

我使用的物品的例子: 在一個房子裏,他們是許多櫥櫃:房子包含房間。每個房間都包含櫥櫃。 對於函數:getMeanValueFromArray,getStdDevFromArray ... 我希望這將澄清問題 – hotips 2010-07-16 10:41:11

回答

4

您所描述的對象所屬的模式,所以他們在application/models去。請記住,模型是與表示層無關的所有內容(例如,MVC中的V和C)。我的建議是有這個結構,那麼:

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文件夾。但是專門爲您的應用製作的所有內容都應該放在模型中

另外,看看ZFPlanet Sample Project by Padraic Brady

+0

我怎樣才能訪問這些對象/功能控制器? 謝謝? – hotips 2010-07-16 11:44:00

+0

@user就像你會訪問你的其他模型類一樣。遵循Zend命名慣例,自動加載器應該處理其餘的事情。 – Gordon 2010-07-16 11:56:06

+0

實際上,默認資源自動加載器在'/ application'下指定了多個不同的目錄來存儲不同的類,例如, '/ application/services','/ application/plugins','/ application/forms'等等。ZF似乎認爲'/ application/models'目錄是存儲業務域對象類和DAL類的地方。這與'模型'有什麼不同的解釋,但是當試圖決定在哪裏放置一個自定義的身份驗證適配器時,會使我們陷入困境。 – 2011-01-12 09:43:44

相關問題