本文介绍了您什么时候使用“ require-dev”?什么是常见的开发依赖项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

虽然我熟悉 composer.json 的基础知识,并在我所需要的 require 键下指定依赖项还不太了解 require-dev 的目的-作曲者的文档指出:

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:

列出开发此软件包或运行测试所需的软件包,
等。默认情况下,
安装根软件包的dev要求。无论安装还是更新,都支持--no-dev选项,即
阻止安装开发依赖项。

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. 实际用途是什么工作流中 require-dev 的情况?

  2. 是否存在应放在<$ c $中的示例软件包(或多个软件包) c> require-dev 但不在 require 中?

  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?


推荐答案

一个常见的示例是phpunit,在开发中需要它来运行您的测试套件,但通常在生产中不需要。也可能是构建工具或类似的东西。不过,将所有内容放入需求并没有太大的危害,这只是意味着您在生产机上安装了更多的代码,并且可能会根据您的操作方式来降低构建速度。

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.

这篇关于您什么时候使用“ require-dev”?什么是常见的开发依赖项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 22:12