Version Constraints

As you start using Composer to manage your dependencies, you need to take care specifying correct version of packages.

Most often you would specify a range because you don’t want to edit composer.json file every time a minor plugin update gets a release.

Version Constraint

The composer has many ways to specify version constraints and also has a section dedicated to it on the official website.

There are five ways to specify non-exact versions for a plugin at version 1.2.

  1. Range (operator-based) e.g. >=1.2 <2.0
  2. Range (hyphen) e.g. 1.2 – 2.0
  3. Wildcard (*) e.g. 1.2.*
  4. Tilde (~) e.g. ~1.2
  5. Caret (^) e.g. ^1.2

All of above can allow you to add a plugin to version 1.2 today and have it updated till 2.0.

At first, tilde and caret may seem confusing, but these links can help understand the difference.

There is also an online semantic version checker tool that you can use. Try it with Laravel and WordPress SEO plugin.

Most article on composer recommends using caret, but it will create a problem for us.

Semantic Versioning (SemVer)

You can read about semantic versioning at in details.

Unfortunately, the majority in WordPress ecosystem doesn’t follow semantic versioning so using caret can create problems. You may be surprised to know that Laravel also doesn’t follow semantic versioning.

Most WordPress plugin developers and even Laravel follows what is called (or trolled) Romantic versioning (RomVer).

Specifying Version Constraint in WordPress

It’s better to use tilde with the minor version specified. In cases, where a plugin is released as 2.4 and not 2.4.0, you can still specify ~2.4.0.

~2.4.0 will get you all updates till 2.5.

In SemVer, you can when using 2.4, you can trust 2.5 blindly. But this is not true in WordPress ecosystem and at most other places.


~2.4 is not same ~2.4.0.

  • ~2.4 means all updates < 3.0
  • ~2.4.0 means all updates < 2.5

So we must specify minor release.

Point Releases

Some plugins/projects follow 0.x version number in an early stage. A recent example is Gutenberg editor in WordPress.

In this case:

  • ~0.2 means all updates < 1.0
  • ~0.2.0 means all updates < 0.3