How to ignore directories with Composer?

This is not possible in Composer. However, there are some ways to do it:

  • When you run the update or install command with --prefer-dist, Composer tries to download the archive on github. You can remove the test directory from the archives by putting this in a .gitattributes file in the root directory of your project:

    Tests/ export-ignore
    
  • Composer will only use the tags on github. Just temporary remove the tests directory when creating a tag will also do the trick.

Leave a Comment