Home  >  Article  >  Backend Development  >  How to Install a Specific Version of a Package with Composer?

How to Install a Specific Version of a Package with Composer?

Susan Sarandon
Susan SarandonOriginal
2024-11-09 10:49:02661browse

How to Install a Specific Version of a Package with Composer?

Installing a Specific Version of a Package with Composer

When attempting to install a specific version of a package using Composer, the default commands ("composer install" and "composer require") typically fetch the latest version. However, there are occasions when an older version is preferred.

Solution: Using the Composer Require Command

To install a specific package version, use the following syntax:

composer require vendor/package:version

For instance, to install version 0.10.2 of the "refinery29/test-util" package, run:

composer require refinery29/test-util:0.10.2

By specifying the version number after the package name, Composer will fetch and install that specific version, allowing you to control the precise package version you want to use in your project.

The above is the detailed content of How to Install a Specific Version of a Package with Composer?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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