Mark Fox
Mark Fox

Reputation: 8924

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?

Upvotes: 6

Views: 2863

Answers (1)

Seldaek
Seldaek

Reputation: 42036

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.

Upvotes: 12

Related Questions