Excluding files from composer packages [duplicate]
Asked Answered
D

1

10

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?

Desmoid answered 1/12, 2013 at 20:25 Comment(0)
O
3

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.

Obbard answered 1/12, 2013 at 21:11 Comment(2)
Thanks - I didn't know composer downloads zips, but that seems reasonable.Desmoid
I realy wonder what the archive exclude function is usefull for. Acording the documentation it should exclude filesRegimentals

© 2022 - 2024 — McMap. All rights reserved.