views:

58

answers:

1

Hi,

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 ?

Thanks in advance

+5  A: 

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)

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.

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

Gordon
How can I access to those objects / functions in a Controller ?Thanks ?
@user just like you would access your other model classes too. Follow the Zend Naming Convention and the autoloader should take care of the rest.
Gordon