Install a specific version of a package with Composer

藏色散人
Release: 2021-06-04 14:17:49
Original
3808 people have browsed it

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!

Install a specific version of a package with Composer

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
Copy after login

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
Copy after login

Add double quotes to use caret or tilde operator in version number.

For example

composer require middlewares/whoops "^0.4"
Copy after login

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 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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template