composer prefer-dist 和 prefer-source 之间的区别?

Difference between composer prefer-dist and prefer-source?(composer prefer-dist 和 prefer-source 之间的区别?)
本文介绍了composer prefer-dist 和 prefer-source 之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

查看PHP Composer的install命令的帮助,看到以下两个选项

Looking at the help for PHP Composer's install command, I see the following two options

$ composer help install
Options:
 --prefer-source            Forces installation from package sources when possible, including VCS information.
 --prefer-dist              Forces installation from package dist even for dev versions.

什么是dist"安装?我浏览了作曲家网站和谷歌,但似乎没有任何东西可以解决这个问题(所以我认为这对于熟悉 Composer 的人来说是核心和显而易见的——为新手问题道歉)

What's a "dist" installation? I poked around the composer site and Google but there didn't seem to be anything that addressed this (So I assume it's something core and obvious to folks familiar with Composer — apologies for the newbie question)

我假设 --prefer-source 是 Composer 向 Packagist 询问存储库位置的位置,然后是 checkout/clone/export/etc.项目本身.

I'm assuming --prefer-source is where Composer will ask Packagist for the repository location, and then checkout/clone/export/etc. the project itself.

如果是这样,那么 --prefer-dist 从哪里下载?它下载什么?

If so, then where does --prefer-dist download from? What does it download?

推荐答案

根据http://getcomposer.org/doc/03-cli.md,--prefer-source 选项将更喜欢创建一个包目录,它是一个版本控制存储库".这相当于您输入:

According to http://getcomposer.org/doc/03-cli.md, the --prefer-source option will prefer to create a package directory that is a "version control repository". This is equivalent to you typing:

$ git clone ...

$ svn checkout ...

--prefer-dist 选项会优先创建一个非版本控制存储库",相当于你输入:

The --prefer-dist option will prefer to create a non-"version control repository", which is equivalent to you typing:

$ git clone ... ; rm -fr dir/.git

$ svn export ...

此外,您可以在 composer.json 中为 sourcedist 定义单独的 repos.这是一个例子:

Also, you can define separate repos for source and dist in your composer.json. Here's an example:

{
    "repositories": [
        {
            "type": "package",
            "package": {
                "name": "joshuaclayton/blueprint-css",
                "version": "master",
                "source": {
                    "url": "git://github.com/joshuaclayton/blueprint-css.git",
                    "type": "git",
                    "reference": "master",
                }
            }
        },
        {
            "type": "package",
            "package": {
                "name": "fiftyone/mobi-lite-php",
                "version": "2013.03.06",
                "dist": {
                    "url": "http://iweb.dl.sourceforge.net/project/fiftyone/51Degrees.mobi-Lite-2013.03.06.php.zip",
                    "type": "zip"
                },
            }
        }
    ]
}

注意:无论出于何种原因,当我使用 --prefer-dist 时,有时会出现诸如

NOTE: for whatever reason, when I use --prefer-dist, I sometimes get errors such as

Fatal error: Cannot redeclare class Zend_Db_Adapter_Pdo_Abstract in ...

当我使用 --prefer-source 时不会出现.出于这个原因,我只使用--prefer-source,直到我找出这个问题的原因.

which do not appear when I use --prefer-source. For this reason, I only use --prefer-source, until I figure out the cause of this issue.

这篇关于composer prefer-dist 和 prefer-source 之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Convert JSON integers and floats to strings(将JSON整数和浮点数转换为字符串)
in php how do I use preg replace to turn a url into a tinyurl(在php中,如何使用preg替换将URL转换为TinyURL)
all day appointment for ics calendar file wont work(ICS日历文件的全天约会不起作用)
trim function is giving unexpected values php(Trim函数提供了意外的值php)
Basic PDO connection to MySQL(到MySQL的基本PDO连接)
PHP number_format returns 1.00(Php number_Format返回1.00)