Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Excluding files from composer packages [duplicate]

I have a PHP library that I've put up on packagist.org. I'd like to exclude certain files from the package (e.g. a couple of JARs, and my tests), so people depending on my library don't have to download them.

I've put the following in my composer.json:

"archive": {
    "exclude": ["/test", "composer.phar", "wiremock"]
}

That doesn't seem to change the contents of the downloaded dependency though.

Does Composer support the feature that I want? And what does my archive/exclude config do?

like image 242
Rowan Avatar asked Dec 01 '13 20:12

Rowan


1 Answers

Composer does not support that as far as I know. In your scenario, the downloading occurs like this: Unless you use the parameter --prefer-source, Composer downloads the .zip archive from Github (for your library, this would be for example https://github.com/rowanhill/wiremock-php/archive/0.1.0.zip). Since this archive has already been prepared by github including all your files, there is no feasible way for composer not to download only a part of your library. If you use --prefer-source, the related tag is being checked out, but still without a filter.

By the way, composer caches the archive downloads, so even if the download is large, it should occur only once.

I am not sure about the archive/exclude part, but my guess would be that this is for generation of a local archive after you downloaded it, e.g. for satis.

like image 102
Florian Holzhauer Avatar answered Oct 10 '22 11:10

Florian Holzhauer