我的 composer.json 文件中的波浪号 (~) 是什么意思?我的、波浪、文件、json

2023-09-06 15:58:00 作者:别看了你帅不过我的

我的 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