> >> I don´t see the point on your proposal.
> >
> > I think the title of my email was a bit ambiguous, specifically I mean
> > re-using such things as domain logic from model classes and common form
> > classes in more than one module.
>
> I agree that I'm missing the point a little bit as well... I use
> something like this:
>
> application/ or repository/
> library/
> My/
> Form/
> Some.php (contains class My_Form_Some)
> Domain/
> Other.php (contains class My_Domain_Other)
>
> Where classes located under "application/" are ment for sharing across
> modules, while in "repository/", more generic (located outside of the
> application directory), for sharing across applications.
If I was to use the layout you mention above, I would have to potentially
package files from three different directory locations.
application/library/My/Form/SomeForm.php
application/library/Domain/OtherModel.php
repository/Some/Other/Class.php
application/module/mymodule
To re-use this module, I have three locations to add to my archive/package.
Also I can't easily share this module, how can I guarantee that the next
developer who wants to use this module has the same layout structure? Does he
use the same loader code? does he use Zend_Loader and autoload? Does he have
SomeForm.php already in his own library?
Not to mention tracking versions of these files in three locations, across
multiple apps.
If I store my models within my module directory, and also any forms I need for
this module. I can easily use svn externals for each module i want to share or
a tarball of the module directory or whatever.
> Include path is set first for application and secondly for repository.
What if I want to share my module ( and by inheritance my model and form code
within the module ) with someone on shared hosting who has no access to modify
the Include path?
> Does this not answer the sharing problem?
In so far as some developers may never have to worry about sharing modules, or
may not have a requirement to do so. A loader helper will not only allow
models to be stored and shared from within a module directory ( the same as if
the models were in "application/models" or "application/library/Domain/" ) but
will make sharing and re-use of modules easier.
Basically, I do this already myself, but I've seen a few enquiries recently
about re-using modules, models and so on. I think it's of value to make steps
to facilitate more sharing of code, and from my point of view there's are
benefits for having your application/modules structured in this way.
If enough people think it's of benefit, great I'll author the proposal, if not
_shrug_ it's a fairly simple helper and not a lot of code anyay ;)
Cheers the noo
Graham
没有评论:
发表评论