Composer 的版本選擇方式

Composer 是目前 PHP 世界裡比較紅的套件管理工具,內建了一些 autoload 模組,以及 Packagist 這個巨大的 ecosystem。

在「Installing Composer Packages」這篇文章裡提到要如何在 Composer 裡指定套件的版本。在這之前,你需要先知道什麼是 Semantic Versioning,然後再來看作者的論述。

直接講結論,文章裡推薦用 ~ 的方式指定版本,這通常會是你要的結果:用 ~1.2 表示 >=1.2.0,<2.0.0;而用 ~1.2.3 則可以表示 >=1.2.3, <1.3

在對付 compatibility 問題時還蠻常見的情況。

Leave a Reply

Your email address will not be published. Required fields are marked *