3

When I do composer install on the production system, should I use the flag --prefer-dist?

--no-dev is recommended, since it prevents the installation of packages that are only needed during development. But what is with --prefer-dist? This flag makes that the installed packages are without VCS stuff, as I read in this answer. I assume that I don't need this on a production machine. Am I right?

Community
  • 1
  • 1
robsch
  • 9,358
  • 9
  • 63
  • 104

1 Answers1

5

The dist file (e.g. tar archive) is usually quicker to download than cloning the repository (which is the case when using --prefer-source).

The main difference is that cloning the repository will give you everything, while a lib maintainer can create the dist itself. This means that they might not include the tests in the dist file for instance. That's why people suggest using --prefer-dist, as it might end up downloading less files.

Anyway, --prefer-dist isn't really needed as Composer always defaults to the dist file when downloading a stable dependency. As it's really a bad practice to have unstable dependencies running in production, you probably end up downloading the dist for all packages anyway (unless you use --prefer-source of course).

Wouter J
  • 41,455
  • 15
  • 107
  • 112