composer.json中的require和require-dev部分之间有什么区别? [英] What is the difference between require and require-dev sections in composer.json?
问题描述
我开始使用composer,对此了解甚少,并且对Web应用程序开发也有一点经验。
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"
}
-
require-dev
部分中出现的内容,仅通过composer install --dev
? - 我阅读了作曲家的一些文档,但仍然不明白我们拥有
require-dev
部分?是因为我们要获取软件包的特定版本而不是始终获取最新的稳定版本吗?
- Whatever appears in
"require-dev"
part, will only be downloaded and installed withcomposer install --dev
? - 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?
推荐答案
不同的环境
通常,软件将在不同的环境中运行:
Different Environments
Typically, software will run in different environments:
-
开发
-
测试
-
分期
-
生产
development
testing
staging
production
<$中声明的依赖项 composer.json
的c $ c> require 部分通常是运行
The dependencies which are declared in the require
section of composer.json
are typically dependencies which are required for running an application or a package in
-
分期
-
生产
staging
production
环境,而在 require-dev $ c $中声明的依赖项c>部分通常是
-
开发中
-
测试
developing
testing
环境。
例如,除了用于实际运行应用程序的软件包,开发该软件可能需要这些软件包,例如:
For example, in addition to the packages used for actually running an application, packages might be needed for developing the software, such as:
-
friendsofphp / php-cs-fixer
(以检测和修复编码样式问题) -
squizlabs / php_codesniffer
(来检测和修复编码样式问题) -
phpunit / phpunit
(以使用测试推动开发) - 等。
friendsofphp/php-cs-fixer
(to detect and fix coding style issues)squizlabs/php_codesniffer
(to detect and fix coding style issues)phpunit/phpunit
(to drive the development using tests)- etc.
现在,在开发
和测试
环境,通常会运行
Now, in development
and testing
environments, you would typically run
$ composer install
要同时安装个产品
和开发
依赖项。
但是,在阶段
和生产
环境ts,您只想安装运行应用程序所需的依赖项,并且在部署过程中,通常会运行
However, in staging
and production
environments, you only want to install dependencies which are required for running the application, and as part of the deployment process, you would typically run
$ composer install --no-dev
仅安装 production
依赖项。
换句话说,这些部分
-
要求
-
要求- dev
require
require-dev
指示作曲者
应该使用哪些软件包在运行时安装
indicate to composer
which packages should be installed when you run
$ composer install
或
$ composer install --no-dev
仅此而已。
注意永远不会安装您的应用程序或程序包所依赖的程序包的开发依赖项
Note Development dependencies of packages your application or package depend on will never be installed
有关参考,请参见:
- https://getcomposer.org/doc/04-schema.md#require
- https://getcomposer.org/doc/04-schema.md#require-dev
- https://getcomposer.org/doc/04-schema.md#require
- https://getcomposer.org/doc/04-schema.md#require-dev
这篇关于composer.json中的require和require-dev部分之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!