开发者

huge zend framework project and where to place models

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

  • put models and shared code under /library
  • make a common module and play with the auto loading to load this classes from any modules
  • dirty but possible setup some symbolic links so the files in models come all from the same source ... but probably bad


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.


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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜