Skip to main content
Software Version / Package Tools

Composer Version Constraint Helper

Understand a Composer version constraint - ^, ~, wildcards, ranges and stability flags - and test which versions it would install.

Enter a constraint from composer.json to see exactly which versions it allows, then test real versions against it with your minimum-stability setting.

Composer resolves all packages together, so a version this tool marks installable can still be ruled out by another package's requirements.

What Is the Composer Version Constraint Helper?

It translates a Composer constraint into plain bounds and checks versions against it using Composer's own rules - including four-part versions, stability suffixes (-alpha1, -beta2, -RC1, -dev) and dev- branches.

When to Use It

  • Choosing a constraint for a new requirement in composer.json.
  • Working out why composer update won't install a version you expected.
  • Moving between npm and Composer, where the same symbols behave differently.

How to Use It

  1. Enter a constraint, or click an example.
  2. Pick your project's minimum-stability (default: stable).
  3. List versions to test - each is marked installable, outside the constraint, or blocked by stability.

Constraint Cheat Sheet

  • ^1.2.3 → >=1.2.3 <2.0.0; ^0.3 → >=0.3.0 <0.4.0.
  • ~1.2 → >=1.2 <2.0 (the last number given may rise) - but npm's ~1.2 means <1.3.0.
  • ~1.2.3 → >=1.2.3 <1.3.0.
  • 1.0.* → >=1.0 <1.1; 1.0 - 2.0 → >=1.0 <2.1.
  • Comma or space means AND; || means OR.
  • @beta, @dev lower the stability allowed for that package only.

Understanding the Result

"Blocked by stability" means the version number fits but it is a prerelease below your minimum-stability. Stability flags (and prerelease versions written in the constraint itself) only take effect in the root composer.json.

Limitations

No Packagist data is fetched - you supply the versions. Branch aliases and prefer-stable are not modelled. For npm ranges, use the Version Range Calculator; to compare two composer.json files, use the Dependency Version Comparator.

Frequently Asked Questions

At least 1.2.0 and below 2.0.0 - any backward-compatible version under SemVer.

In Composer, ~ lets the last specified number rise, so ~1.2 means >=1.2 <2.0. npm's ~1.2 means <1.3.0, which is a common source of confusion.

minimum-stability defaults to stable. Add a flag like "^2.0@beta" to that requirement, or lower minimum-stability in composer.json.
Share this tool: