Sign up ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

Regarding source folder hierarchy, there are always some common features, such as the src, doc or test folders, which have rather easy-to-understand contents.

However, I realized that big projects have both a lib and vendor folders, while I had always thought they were the same, as their names hint at including “third-party libraries from external vendors”. Though, seeing both in the same project means there is a difference.

I couldn't find any information nor on Google nor on sources such as the Filesystem Hierarchy Standard, even though this is actually a somehow common practice.

Here is a more detailed example with Symfony: once you create a project, you get a lib folder at the root of your project. In this folder, the following structure is found:


Here, the symfony folder contains all Symfony's core.

share|improve this question
@YannisRizos I know it's not in their source. Once you start working on a project and generate modules, though, you'll end up with lib/vendor and other directories along vendor. And they're not the only ones. “everyone can select any dir structure” Yeah well, thanks. Everyone can code however they want. If I want to call src “woudzigouga”, I can. I'm not asking whether I can but why others that are serious and well-known do something that looks like a good practice. –  MattiSG Dec 5 '11 at 10:02
Other than the obvious, that lib holds core libraries (absolutely essential libraries OR libraries built from the same author as the framework) and vendor holds third party libraries, I don't think there's any other sane distinction. That distinction is somewhat important for a variety of reasons, and it makes sense as a generic practice. –  Yannis Dec 5 '11 at 10:27
btw, could you add the clarifications in the comments to the question itself? –  Yannis Dec 5 '11 at 10:30
@YannisRizos What clarifications? The Google Code search proving my question isn't totally bogus? It would actually be helpful if you could detail the “variety of reasons” for which the distinction is important, as well as explain how some included third-parties can be more essential than others — if they are included, there's a reason, unless the maintainers are incompetent and batch-include code. –  MattiSG Dec 5 '11 at 10:41
The Google Code search proving my question isn't totally bogus? Mostly that. It backs your claim that both directories are common. You should always back your claims in questions. btw this isn't for me, I know both directories are common, but no reason not to add the search in the question. as well as explain how some included third-parties can be more essential than others Writing an answer, and that's not exactly what I wrote in the comment there's an OR there... –  Yannis Dec 5 '11 at 10:46

3 Answers 3

When I see a lib or libraries directory, I think of:

  • Libraries, not plugins, modules, etc.
  • OOP instead of procedural, where that's applicable (i.e. PHP)

When I see a vendor directory, I think of:

  • Libraries, plugins, modules, components, etc. Not just libraries, but anything that's provided by a third party.
  • And stuff that's not code, like an icon set.

When I see lib and vendor directories, I think of a few distinctions:

  1. lib holds only libraries, vendor may hold anything really,
  2. lib is where I should put my libraries, vendor where I should put anything third party (including code by the original author),
  3. lib is where libraries by the original author of the project are located (if that's not me), whereas vendor is where the original author put third party anything.
  4. You can safely assume that whatever is in lib is licensed under the same license as the rest of the project.

Whichever one of the above applies, is reason enough to have different folders. AFAIK there is no generally accepted practice. Some communities have community wide common practices, but that's just about it.

As for the specific Symfony example: Symfony is a framework and I think what the developers are trying to say is that in a Symfony application the framework's core libraries are vendor code, i.e. coming from a third party and not from the original author of the application (you).

share|improve this answer
“Stuff that's not code” would be in data or resources (or something more precise along the lines of img), IMHO. Moreover, in our Symfony example, vendor actually contains all Symfony core, so unless I don't get your “original author” denomination, I don't think that fits your points 2 and 3. –  MattiSG Dec 5 '11 at 11:13
@MattiSG Ah, sorry, I'm not saying it should fit all four points. Just one. And "Stuff that's not code" should be in a resources or assets directory, but depending on the project it could make sense in a vendor directory (I prefer assets really). –  Yannis Dec 5 '11 at 11:15
What's better singular or plural? lib vs libs and vendor vs vendors ? –  Quang Oct 17 '12 at 19:24
@Quang Most popular projects I've seen use singular, but I have no idea which one is better. –  Yannis Oct 17 '12 at 19:25
@YannisRizos Thanks :) –  Quang Oct 20 '12 at 14:44
up vote 11 down vote accepted

Generalizing @WayneM's answer but not daring to edit it so much.

So, it seems this structure can be observed in application frameworks (Rails and Symfony at least).

It is a way to keep the lib / src structure intact for application developers, while adding the other level of distance brought by the use of a framework: the vendor folder actually contains the framework's libraries, leaving the lib folder for the application's included libraries, and src for its source files.

It is a “more distant” lib, vital since without the framework, the application is useless, but not to be touched by the application's developer: it is the framework vendor's libraries.

share|improve this answer

In the case of something like Symfony, lib is the application code (i.e. written by the developers) and vendor is third-party code. Think of it like lib is what the src folder normally is, and vendor is lib. I normally see that style in PHP because you separate out the html templates from the actual classes.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.