Reputation: 27323
We have a huge Zend Framework project, it's basically a website in 4 different languages and with a fair amount of pages. Usually my application handle 10~15 database tables and probably 5/6 controllers so I place all my model under applications/models
.
The problem with that project doing the same would make copy the same models in each modules and probably make a lot of duplicate code and make the maintenance being difficult. I am wondering if it would wise to puts the models under library
?
How do you people are doing in such case? some solutions, I am thinking of in my order of preference
/library
Upvotes: 1
Views: 331
Reputation: 6431
This is how I typically structure my application, although I have stored them in the library
folder in other projects. I prefer this structure over storing them in the library as Models are application specific, whereas my library is used to store application-less(?) classes (typical Auth, Filters etc)
/application
/models
// Models
/modules
/default
/controllers
// Default Controllers
/admin
/controllers
// Admin Controllers
/library
// Library Classes
Upvotes: 1
Reputation: 53636
I keep all library code, including models, under /library. IMO, that's what it's there for. Then, if you need to share libraries (incl. models) between apps, you can do so with a single symlink or git submodule:
Your local app:
/myapp/application/
/myapp/public/
/myapp/library/
/myapp/library/MyApp/
Pulling in external dependencies:
/myapp/library/OtherLib (git submodule of a separate repo)
/myapp/library/ExtraLib (symlink to /path/to/ExtraLib/)
Or:
set_include_path(get_include_path() . ':/path/to/ExtraLib')
If you separate models from the library, you'd have two mount points for every dependency.
Upvotes: 3