Here is a short and quick article for How To Install Specific Version of Package using Composer
composer require vendor/package:version //Example composer require laravel/passport:6.0
Navigate to the project root directory in the terminal and execute the following command to install the specific version of a package using Composer
Let’s suppose you are looking to install version 6.0.0 of package larvael/passport to your project, instead of 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.
Use coupon 5balloons on this Cloudways Affiliate URL to get special discount.
composer require middlewares/whoops "^0.4"
Tilde Version Range (~) – ~1.2.3 is equivalent to >=1.2.3 <1.3.0
Caret Version Range (^) – ^1.2.3 is equivalent to >=1.2.3 <2.0.0
So, with Tilde you will get automatic updates of patches but minor and major versions will not be updated. However, if you use Caret you will get patches and minor versions, but you will not get major (breaking changes) versions.
Tilde Version is considered a “safer” approach, but if you are using reliable dependencies (well-maintained libraries) you should not have any problems with Caret Version (because minor changes should not be breaking changes.