Say I'm trying to install a package that has a 1.0 branch and a master branch. The 1.0 branch has tags like 1.0.1, 1.0.2, etc.
What I want to be able to do is to install the latest version in the branch. I don't want to install a tagged release - I want to install the latest branch version.
Here's what I tried:
composer require package/package:1.0
composer require package/package:~1.0
Both of those got the most recent 1.0.* tag but not the latest in the 1.0 branch.
Is what I'm trying to do even possible?
For that matter what even is the difference between 1.0
and ~1.0
?
update / u / upgrade# In order to get the latest versions of the dependencies and to update the composer.lock file, you should use the update command. This command is also aliased as upgrade as it does the same as upgrade does if you are thinking of apt-get or similar package managers.
In the case of composer update , it does not use the lock file, instead it uses the composer. json file and updates the packages(if updates have been released in the last 3 months).
To update dependencies two commands can be used: composer update and composer require . The difference between these two commands is that composer update will try to update a dependency based on the current constraints in composer. json and will only update composer. lock .
You can require dev-master
as the version name (or dev-branchName), and it will pull in the most recent commit from the specified branch. For versioned branch names, use e.g. 2.0.x-dev
as the version name instead.
(More details are available on the Schema - package links section of the Composer documentation.)
The difference between 1.0
and ~1.0
is that 1.0
specifies a specific version number, and ~1.0
specifies that any version "compatible" (according to semantic versioning) with 1.0 is allowed. From the Composer documentation:
The ~ operator is best explained by example:
~1.2
is equivalent to>=1.2 <2.0.0
, while~1.2.3
is equivalent to>=1.2.3 <1.3.0
.
There is also the similar ^ operator: ^1.2.3
is equivalent to >=1.2.3 <2.0.0
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With