Why are there two “vendors” folders in CakePHP?

You probably noticed that there are two “vendors” folders in CakePHP: one is directly in the root and the other in the “app” folder. So, why are there two such folders? It is simple. The “vendors” folder in the “app” folder is for application-specifc third-party libraries whereas the other “vendors” folder is for libraries you want to use in multiple applications.

8 Comments

  1. nate
    Posted August 11, 2006 at 4:32 pm | Permalink

    Also, the root vendors folder has js/ and css/ folders that allow you to store JavaScript and CSS files that are globally available to all applications, just as if they were in webroot/js or webroot/css. And since the files are served through PHP, you can embed PHP code in them.

  2. nao
    Posted August 11, 2006 at 5:18 pm | Permalink

    Hello Nate,

    Since what version of CakePhp for this improvements ?

    Can you give me some examples how to embed PHP code in CSS files and how to call css or js from vendors folders ?

    Thanks,

    Nao

  3. nate
    Posted August 11, 2006 at 5:22 pm | Permalink

    The feature has been there for a couple months. Loading JS and CSS files from vendors is seamless. It’s the exact same as loading JS or CSS files from webroot.

  4. nao
    Posted August 11, 2006 at 5:23 pm | Permalink

    And for embed PHP code in them ?

  5. nao
    Posted August 11, 2006 at 5:42 pm | Permalink

    I have make a file “test.js” in root vendors folder but file are not loaded :

    link(‘test’); ?>

  6. nate
    Posted August 11, 2006 at 6:31 pm | Permalink

    Try addressing your questions to the mailing list.

  7. Posted December 2, 2006 at 6:23 pm | Permalink

    What exactly are these folders for? Am I supposed to put third-party classes here? For example: ezsql, paginator, smarty, xajax, etc.

    Would these be considered appropriate names for “vendors”? The name is a little confusing to me. Wouldn’t “classes” have been a better name then?

    How about files with purely functions in them (stuff like capFirstLetter, doSomethingWithString, etc)? Should I make helpers/components of those or can I simply throw the files into a single vendor folder as well?

  8. Posted December 3, 2006 at 3:37 pm | Permalink

    @Ken: The vendors folders are thought for third-party classes. You can name folders inside of vendors in any way you like.

    I think it depends on where you want to use the functions. If you use the functions only in views, make a helper. If you use the functions only in controllers, create a component. Otherwise put them in the vendors folder.


%d bloggers like this: