使用“require-dev”在作曲家中安装软件包 [英] Using "require-dev" to install packages in composer

查看:105
本文介绍了使用“require-dev”在作曲家中安装软件包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始使用作曲家,我对此很少了解,并且对网络应用程序开发有一点经验。

I'm beginning using composer, I know so little about it and have a little experience with web application development.

我只是走过Nettuts+教程,因此我有关于作曲家的基本问题。

I just walk through Nettuts+ Tutorial, so I have basic question about composer.

{
  "require": {
    "laravel/framework": "4.0.*",
    "way/generators": "dev-master",
    "twitter/bootstrap": "dev-master",
    "conarwelsh/mustache-l4": "dev-master"
  },
  "require-dev": {
    "phpunit/phpunit": "3.7.*",
    "mockery/mockery": "0.7.*"
  },
  "autoload": {
    "classmap": [
      "app/commands",
      "app/controllers",
      "app/models",
      "app/database/migrations",
      "app/database/seeds",
      "app/tests/TestCase.php"
    ]
  },
  "scripts": {
    "post-update-cmd": "php artisan optimize"
  },
  "minimum-stability": "dev"
}




  1. 无论require-dev部分中显示什么,都只能通过 composer install --dev

  2. 我读了一些作曲家的文档,但仍然不明白我们有require-dev部分的原因是什么?是因为我们想要获取特定的版本,而不是获得最新的稳定版本?

  1. Whatever appears in "require-dev" part, will only be downloaded and installed with composer install --dev?
  2. I read some of composer's documentation but still don't understand what is the reason we have "require-dev" part? Is it because of we want to get specific version of the package rather always getting the latest stable version?


推荐答案


  1. 根据作曲家手册:

  1. According to composer's manual:


require-dev(root-only)

列出开发此软件包或运行测试等所需的软件包。默认安装。 安装更新支持 - 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.

因此,运行 composer install 将会也下载了开发依赖。

So running composer install will also download the development dependencies.

原因其实很简单。当贡献给特定的库,你可能想运行测试套件或其他开发工具(例如symfony)。但是如果您将这个库安装到项目中,则可能不需要这些开发依赖项:并非每个项目都需要测试运行器。

The reason is actually quite simple. When contributing to a specific library you may want to run test suites or other develop tools (e.g. symfony). But if you install this library to a project, those development dependencies may not be required: not every project requires a test runner.

这篇关于使用“require-dev”在作曲家中安装软件包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆