Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When do you use "require-dev"? What are common dev dependencies?

While I'm familiar with the basics of composer.json and specifying dependencies under the require key I haven't quite understood the purpose of require-dev — Composer's documentation states:

require-dev (root-only)

Lists packages required for developing this package, or running tests, etc. The dev requirements of the root package are installed by default. Both install or update support the --no-dev option that prevents dev dependencies from being installed.

In the abstract it makes sense, but I'm having a hard to imagining the situations when I'd need this functionality.

  1. What are the practical use cases of require-dev in a workflow?
  2. Is there an exemplar package (or packages) which should reside in require-dev but not in require?
like image 281
Mark Fox Avatar asked Aug 29 '13 20:08

Mark Fox


1 Answers

One common example is phpunit, which you need in development to run your test suite, but generally won't need in production. It could also be build tools or such things. There is no huge harm in putting everything into require though, it just means you have more code installed on your prod machines, and might slow down your builds a bit depending on how you do them.

like image 130
Seldaek Avatar answered Oct 25 '22 13:10

Seldaek