composer.json如何记录--prefer-source [英] How does composer.json record --prefer-source

查看:66
本文介绍了composer.json如何记录--prefer-source的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以使用-prefer-source 选项从命令行添加软件包。
当然应该导致对 composer.json 的更改吗?
如何显示?使用-prefer-source 后看不到任何区别。

One can add a package from the command line with the --prefer-source option. Surely should result in a change to composer.json? How is this shown? I can't see any difference after using --prefer-source.

推荐答案

如果您-首选源或<$,则 composer.json 文件中没有记录差异c $ c>-prefer-dist 。唯一的事情就是软件包本身的名称和版本约束。

There is no difference recorded in the composer.json file if you --prefer-source or --prefer-dist. The only thing is the name and version constraint for the package itself.

差异可能出现在 composer.lock 内部并放在供应商文件夹中。如果已经安装了软件包,它们的状态将以​​它们在供应商文件夹中的显示方式反映出来。如果它们是已签出的存储库,则Composer将继续将它们视为-prefer-source ,这可能会在切换到不同版本时加快某些操作。如果没有存储库,Composer将继续将该文件夹视为-prefer-dist

The difference may occur inside composer.lock and in the vendor folder itself. If packages are already installed, their state is reflected in the way they are present in the vendor folder. If they are a checked-out repository, then Composer will continue to treat them like --prefer-source, which might speed up some operations when switching to different versions. If there is no repository, Composer will continue to treat that folder as --prefer-dist.

dist 仅在 composer.lock中记录了适当的信息后才有效。 。没有记录 dist 的下载位置,安装依赖项将导致检出存储库,反之亦然。如果两种信息均可用,并且其中一种方法失败,则尝试另一种方法,即,如果下载链接失败,则执行检出。

Note that either source or dist will only work if the appropriate information has been recorded in composer.lock. Without a download location for dist recorded, installing the dependencies will result in a checkout of the repository, and vice versa. If both information is available, and one of the methods fails, the other one is tried, i.e. if the download link fails, a checkout is performed.

-prefer-source 选项实际上只会影响下载和安装本身,而不会影响记录依赖项的方式-这很有意义,因为您可能希望在开发时将源签出,但是在部署到生产环境时,您不想克隆整个存储库。使用 composer install 的命令行标志,您可以在将依赖项安装到新的供应商文件夹中时随时改变主意,如果将其安装到现有的供应商文件夹中,则保留先前的选择。

The --prefer-source option really only affects the download and install itself, not the way how the dependency is recorded - which makes sense, because you might like to have the source checked out when developing, but you don't want to clone entire repositories when deploying to production. With the command line flag for composer install you can change your mind anytime you install dependencies into a fresh vendor folder, and your previous choice is kept if installing into an existing vendor folder.

这篇关于composer.json如何记录--prefer-source的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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