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

余生长醉 提交于 2019-12-06 03:58:26

问题


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?

回答1:


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.



来源:https://stackoverflow.com/questions/18520121/when-do-you-use-require-dev-what-are-common-dev-dependencies

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!