Home / Snippets / How to Install a Specific Version of Package Using Composer?
How to Install a Specific Version of Package Using Composer? cover

How to Install a Specific Version of Package Using Composer?

1.8K

3 years ago

0 comments

Sometimes you might need to specify different package versions when installing a Composer dependency and to do that you can pass in the version after the package name.

Default Composer Require Command


The default way of installing/requiring a package is as follows. By default, this will install the latest available package for the project.
composer require vendor/package

Composer Require Command With Package Version


To specify the version number you can pass in after the package name like below. Do note that the version must be the version of how the package vendor specifies it. 
composer require vendor/package:version
So let's say you are installing the Intervention Image package which is to manipulate Image, you can write your command like below.
comopser require intervention/image:2.6.0
The benefit of specifying the package version is that sometimes the latest version of the package has a higher dependency requirement than your current project, so the only way to have the package is to install the older version.

Other Reads

notion avatar

Alaz

Week-end developer currently experimenting with web, mobile, and all things programming.

Topics:

Frontend

Resource

Average

Average

Support Us

If you like our tutorial, support us by being our Patreon or buy us some coffee ☕️

Welcome to PostSrc V3

PostSrc Dark Logo

You have to login to favorite this