Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the tilde (~) mean in my composer.json file?

People also ask

What is tilde in composer json?

Tilde means next significant release.

What is inside composer json?

composer. json Is just a config file that describes your application, and its needs !! By that I mean, your application, its version, and what it needs to work properly (also known as the dependency) can all be written inside the composer.

What is mean of in Composer version?

In Composer, what's often referred to casually as a version -- that is, the string that follows the package name in a require line (e.g., ~1.1 or 1.2. * ) -- is actually more specifically a version constraint.

How do I change the composer json file?

To update your packages json file is. Run composer update (on your local machine) to update the required packages and re-generate a composer. lock file. Commit the updated composer.


Tilde means next significant release. In your case, it is equivalent to >= 2.0, < 3.0.

The full explanation is at Tilde Version Range docs page:

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.

Another way of looking at it is that using ~ specifies a minimum version, but allows the last digit specified to go up.

Seldeak's below comment is a simple sum up explanation of the Composer documentation.


Tilde operator is useful for the projects that version their libraries using semantic versioning scheme.

Semantic versioning is more of a guideline that evaluates to the next significant release.

For Composer, this operator means to allow minor releases (that can include patches) without allowing a major version (that may not be backward compatible) while installing and updating.

For example: ~4.1 will allow project versions >=4.1 but <5.0.

Credits: http://dwellupper.io/post/37/using-tilde-range-operator-to-resolve-dependency-version-in-composer-php