I don't understand what the composer ^ symbol means?

WBOY
Release: 2016-08-10 09:07:26
Original
1737 people have browsed it

这是官网的话
Caret#

The ^ operator behaves very similarly but it sticks closer to semantic versioning, and will always allow non-breaking updates. For example ^1.2.3 is equivalent to >=1.2.3 <2.0.0 as none of the releases until 2.0 should break backwards compatibility. For pre-1.0 versions it also acts with safety in mind and treats ^0.3 as >=0.3.0 <0.4.0.

This is the recommended operator for maximum interoperability when writing library code.

Example: ^1.2.3
Composer

回复内容:

这是官网的话
Caret#

The ^ operator behaves very similarly but it sticks closer to semantic versioning, and will always allow non-breaking updates. For example ^1.2.3 is equivalent to >=1.2.3 <2.0.0 as none of the releases until 2.0 should break backwards compatibility. For pre-1.0 versions it also acts with safety in mind and treats ^0.3 as >=0.3.0 <0.4.0.

This is the recommended operator for maximum interoperability when writing library code.

Example: ^1.2.3
Composer

@查尔斯 ~^的意思很接近,在x.y的情况下是一样的都是代表x.y <= 版本号 < (x+1).0,但是在版本号是x.y.z的情况下有区别,举个例子吧:

  • ~1.2.3 代表 1.2.3 <= 版本号 < 1.3.0

  • ^1.2.3 代表 1.2.3 <= 版本号 < 2.0.0

详见: https://getcomposer.org/doc/a...

感谢 @北月武士 指正

^符号意思,用于匹配下一个重要版本

举例:

composer.json

<code>{
    "require": {
        "topthink/framework": "^5.0-rc1"
    }
}</code>
Copy after login

执行sudo composer install 以后效果如下

I don't understand what the composer ^ symbol means?

匹配到了composer库详情页的最新一个重要版本

I don't understand what the composer ^ symbol means?

https://packagist.org/package...

另外备注下:犯这个错误是因为一个前提条件,我一般只关心次版本号,而不会关心修正号,所以如果你一直指定~x.y和^x.y的确是一样的,哪怕库的版本号就是用x.y.z的版本规范命名的

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!