這是官網的話
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
的情況下有區別,舉個例子吧:
詳見: https://getcomposer.org/doc/a...
感謝 @北月武士 指正
^符號意思,用於匹配下一個重要版本
舉例:
composer.json
{ "require": { "topthink/framework": "^5.0-rc1" }}
執行sudo composer install 以後效果如下
匹配到了composer庫詳情頁的最新一個重要版本
https://packagist.org/package...
另外備忘下:犯這個錯誤是因為一個前提條件,我一般只關心次版本號碼,而不會關心修正號,所以如果你一直指定~x.y和^x.y的確是一樣的,哪怕庫的版本號碼就是用x.y.z的版本規範命名的