So do you put modules you share between projects inside the library folder and not inside application/modules?

On 3/28/2010 8:37 PM, Hector Virgen wrote:
I think it all depends on how those classes are written. If they are tied directly to your application, then I would place them under application/models. I do this with my custom auth adapter that implements Zend_Auth_Adapter_Interface.

But if you write your code to be configurable so that it could be reused in more projects, then it should go in library/Company. For example, a custom Auth Storage class could be reused by other applications, while your custom ACL may be tied directly to the business rules of your app.

--
Hector


On Sun, Mar 28, 2010 at 12:39 PM, Chris Morrell <[email protected] <mailto:[email protected]>> wrote:

    OK, that makes sense.  The only thing I have a question about is:

        I'd typically put action helpers under
        application/controllers/helper (which is noted in our
        recommended directory structure as well). usually use library/
        only for code I want to re-use between _projects_.

    Putting action helpers in application/controllers/helper makes
    perfect sense.  But what about things like a custom Acl class, or
    a custom Auth adapter or Auth storage class?  Maybe those don't
    make sense in the library directory, but are there any standard
    places to put that stuff?

    CM

    <http://cmorrell.com/>        *Chris Morrell*
    Web:        http://cmorrell.com <http://cmorrell.com/>
    Twitter:    @inxilpro <http://twitter.com/inxilpro>


    On Sun, Mar 28, 2010 at 11:31 AM, Matthew Weier O'Phinney
    <[email protected] <mailto:[email protected]>> wrote:

        -- Chris Morrell <[email protected]
        <mailto:[email protected]>> wrote
        (on Saturday, 27 March 2010, 12:00 AM -0400):
        > I always thought that Default_ was the recommended namespace
        for everything
        > under the application/ tree that's part of the default
        module, and that
        > Application_ was becoming the standard for
        library/application/.  Have I always
        > been mistaken or has this changed recently?

        In 1.10, we put in infrastructure for naming the default
        module and
        thus prefixing resources from that module. We'd originally
        recommended
        "Default_", but felt this led to some confusion and potential
        issues:

         * Modules are prefixed using the module name, which is the
        name of
          their parent directory. But the "default" module is named
        after...
          what? its parent directory is "application"...

         * Typically, the resources in your default module are meant
        to be used
          "application"-wide, not just by that module. "Application"
        is thus a
          better name.

        The change we made is completely backwards compatible, as all that
        really changed is that Zend_Tool now creates a configuration
        entry that
        sets the prefix for you.

        As for having a "library/Application" directory, I'm not
        familiar with
        this practice, believe it or not.

        > This always made sense to me:
        >
        > application/
        >   controllers/  →  *Controller

        This stays the same.

        >   forms/  →  Default_Form_*
        >   models/  →  Default_Model_*

        These now would be prefixed "Application_<component>_"

        >   modules/
        >     admin/  →  Admin_*
        >     blog/  →  Blog_*

        These stay the same.

        > library/
        >   Zend/  →  Zend_* (if ZF is not in global include_path)
        >   MyCompany/  →  MyCompany_* (shared components within
        company, etc)
        >   Application/  →  Application_* (components specific to
        application that don't
        > fall under modules, such as a custom Action Helper)

        I'd typically put action helpers under
        application/controllers/helpers
        (which is noted in our recommended directory structure as well). I
        usually use library/ only for code I want to re-use between
        _projects_.

        > Now that application/ maps to Application_ (which makes
        sense from a directory
        > naming perspective, but not so much from a modular
        perspective), is the
        > recommendation that you give your application-wide library an
        > application-specific namespace?
        >
        > CM : http://cmorrell.com/ — @inxilpro
        >
        >
        >
        > On Fri, Mar 26, 2010 at 1:29 PM, Matthew Weier O'Phinney
        <[email protected] <mailto:[email protected]>>
        > wrote:
        >
        >
        >     "Application" is what we specify as the default for
        resources under the
        >     "application" tree -- but even this is fully
        configurable, and I'd
        >     recommend using one that's project specific.
        >

        --
        Matthew Weier O'Phinney
        Project Lead            | [email protected]
        <mailto:[email protected]>
        Zend Framework          | http://framework.zend.com/
        PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc



Reply via email to