Home >Development Tools >composer >Install a specific version of a package with Composer
The following column composer tutorial will introduce you to using Composer to install a specific version of the software package. I hope it will be helpful to friends in need!
This is a short and quick article on how to install a specific version of a package using Composer
TL;DR version
composer require vendor/package:version //Example composer require laravel/passport:6.0
Detailed version
Navigate to the project root directory in the terminal, execute the following command, use Composer to install a specific version of the package
Assume you want Install version 6.0.0 of the larvael/passport package into your project instead of installing the latest version. Then you should execute the following command
composer require laravel/passport:6.0.0
Add double quotes to use caret or tilde operator in version number.
For example
composer require middlewares/whoops "^0.4"
Tilde version range (~) – ~1.2.3 is equivalent to >=1.2.3 614cd2a4a95f8b9664d8f7b55e0f8d09=1.2.3 <2.0.0
So with tilde you will get automatic updates for patches, but not for minor and major versions. However, if you use Caret, you will get patches and minor releases, but not major (breaking change) releases.
Tilde Version is considered a "safer" approach, but if you use reliable dependencies (well-maintained libraries), you shouldn't have any problems using Caret version (because of small changes Changes should not be broken.
This article is a literal translation from English. If you have any questions, please visit the original text: https://5balloons.info/install-specific-version-of-package-using-composer/
The above is the detailed content of Install a specific version of a package with Composer. For more information, please follow other related articles on the PHP Chinese website!