It’s one of the best kept secrets of popular PHP dependency manager Composer: How to flush composers cache.
You normally don’t need it, however if you create some composer.json and you want to put it to a test, this can be useful to know. Or let’s imagine your composer cache grows some gigabytes large. Here are two ways:
First, you can just nuke it from above:
$ rm -rf "`composer config cache-dir`"
(if you’re using Windows, use git-bash.)
The second way is to tell Composer where to find the cache via environment variables:
$ COMPOSER_CACHE_DIR=/dev/null composer install
This second method is perhaps better if in your tests you don’t want to influence the whole system.
The third but not yet available method is to make use of a composer command. This is discussed in the feature request Add command to clear composer cache which also exchanges some arguments pro and con. But I though I spare that for this little TLDR; type of blog-post.
Update 5 Jun: Just in a recent Pull-Request “Add clear cache command” (#3034) such a concrete command has been offered to merge by David Neilsen.
Update 14 Jul: See as well If all else fails Slide of Using composer correctly (confoo) (26 Feb 2014 by Igor Wiedler).
It’s a little hard to find the composer clear-cache command from the linked pull-request and issue, may I recommend updating the syntax in the main article since composer clear-cache now exists?
What about: composer clearcache
You name it. Just went golden some days after posting.
Thank You
Nothing to thank for, it’s a pleasure for me to link all this. It’s solved nowadays but perhaps not always accessible so great the posting helped you!