我的 composer.json 文件中的波浪号 (~) 是什么意思? [英] What does the tilde (~) mean in my composer.json file?

查看:22
本文介绍了我的 composer.json 文件中的波浪号 (~) 是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 composer.json 文件中有这一行:

I have this line in my composer.json file:

"require": {
    ...
    "friendsofsymfony/user-bundle": "~2.0@dev",
    ...
},

~2.0@dev 中的波形符 ~ 到底是什么意思?那是一个占位符并且应该总是获取像 1.2.02.2.03.2.0 等这样的颠覆吗?没有意义(将由 * 通配符完成).

What does the tilde ~ in ~2.0@dev exactly mean? Is that a placeholder and shall always fetch the subversions like 1.2.0, 2.2.0, 3.2.0 and so on? Doesn't make sense (and would be done by the * wildcard).

composer.json 文档没有说明任何关于波浪号的信息.

The composer.json documentation doesn't tell anything about the tilde.

我之所以问,是因为我刚刚读到 Symfony 博客中的安全问题,他们建议升级到1.3.3 版.但是弄清楚 FOSUserBundle 的版本并不容易(我找不到包含该版本的文件).

I am asking because I just read about a security issue in the Symfony blog and they recommend to upgrade to version 1.3.3. But figuring out the FOSUserBundle's version isn't that easy (I couldn't find a file that contains the version).

推荐答案

波浪号表示下一个重要版本.在您的情况下,它相当于 >= 2.0, <3.0.

Tilde means next significant release. In your case, it is equivalent to >= 2.0, < 3.0.

完整的解释在 波浪号版本范围文档页面:

~ 操作符最好用例子来解释:~1.2 等价于 >=1.2 <2.0.0,而 ~1.2.3 等价于 >=1.2.3 <1.3.0.

The ~ operator is best explained by example: ~1.2 is equivalent to >=1.2 <2.0.0, while ~1.2.3 is equivalent to >=1.2.3 <1.3.0.

另一种看待它的方式是使用 ~ 指定一个最小值版本,但允许指定的最后一位数字上升.

Another way of looking at it is that using ~ specifies a minimum version, but allows the last digit specified to go up.

Seldeak 的以下评论是对 Composer 文档的简单总结说明.

Seldeak's below comment is a simple sum up explanation of the Composer documentation.

这篇关于我的 composer.json 文件中的波浪号 (~) 是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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