just getting started with composer and I have a couple of questions.

When I use composer to add a dependency, the dependency gets added to my folder's Vendor directory. The newly added package not only comes with the source code for that package, but all packagist required files for the developer to test and add that package to packagist repo (composer.json, .travis.yaml, license, readme.md, etc).

For my project, do I need to keep the vendor's required packagist files in my project?

Can I clean the package folder structure up a little?

I added the package, Slim micro framework, which nests the source files three directories deep upon installation, ../vendor/slim/slim/Slim/(source Files). Is it worth moving these files to the top Slim directory like: ../vendor/Slim/(source files)? Or will this ruin the integrity of the package?

  • 3
    Why do you want to "clean the package folder structure up a little"? If you leave your vendor folder as composer wants it'll be easy to get updates later. If you mess with it won't. Why not just leave it and get on with your code? – James Nov 9 '13 at 22:02
  • Thanks for the feedback ... And that's exactly what I was asking, if moving files around would ruin the integrity of the package ... Sounds like it will ... I only ask because looking at the folder of a package and it's sort of a mess of files, and if you have more than one package, there's that many folders that are unorganized ... I'm just a fan of keeping things organized, clean, dry as possible. But if it's best practice to keep all files where they are at with composer than so be it – kdub Nov 10 '13 at 1:07

The answer is simply: You shouldn't mess with the directories.

Here's why: Every Composer package is structured like the following vendor/packageName/[actualCode].

If you have multiple packages from the same vendor, let's say package A from C and package B from C, it'll look this way:



If you now put the code directly to the vendor directory, composer won't find the package anymore.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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