Jimmix
Jimmix

Reputation: 6506

Composer install package from cache

I'm using php composer 1.8.0 that I installed to docker php:7.3-cli

Every time I install packages with this composer it downloads package, even the package was previously downloaded.

  1. Where does composer has its cache for the packages it downloaded?

  2. Is there any command line option or other to set a particular dir as a composer cache?

Upvotes: 1

Views: 1759

Answers (1)

atline
atline

Reputation: 31584

See this:

The COMPOSER_CACHE_DIR var allows you to change the Composer cache directory, which is also configurable via the cache-dir option.

By default it points to $COMPOSER_HOME/cache on *nix and macOS, and C:\Users\\AppData\Local\Composer (or %LOCALAPPDATA%/Composer) on Windows.

The COMPOSER_HOME var allows you to change the Composer home directory. This is a hidden, global (per-user on the machine) directory that is shared between all projects.

By default it points to C:\Users\\AppData\Roaming\Composer on Windows and /Users//.composer on macOS. On *nix systems that follow the XDG Base Directory Specifications, it points to $XDG_CONFIG_HOME/composer. On other *nix systems, it points to /home//.composer.

So, by default, I guess, you need to use -v to mount a host path as volume to container to override the COMPOSER_CACHE_DIR in container. Then everytime you start a new container, it could reuse the packages before.

Upvotes: 1

Related Questions