composer ^ 這個符號什麼意思不太明白?

來源:互聯網
上載者:User
這是官網的話
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

{    "require": {        "topthink/framework": "^5.0-rc1"    }}

執行sudo composer install 以後效果如下

匹配到了composer庫詳情頁的最新一個重要版本

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

另外備忘下:犯這個錯誤是因為一個前提條件,我一般只關心次版本號碼,而不會關心修正號,所以如果你一直指定~x.y和^x.y的確是一樣的,哪怕庫的版本號碼就是用x.y.z的版本規範命名的

  • 相關文章

    聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.