To ensure that the versions are listed in the correct order with the latest on top in Packagist, you should follow semantic versioning and use proper pre-release identifiers. Here are some recommendations:
-
Semantic Versioning: Follow semantic versioning (SemVer) strictly. The format is
MAJOR.MINOR.PATCH, where:MAJORversion increments for incompatible changes.MINORversion increments for backward-compatible functionality.PATCHversion increments for backward-compatible bug fixes.
-
Pre-release Identifiers: Use pre-release identifiers (e.g.,
alpha,beta,rc) with a numeric suffix to maintain proper order. The format isMAJOR.MINOR.PATCH-<identifier>.<number>. -
Release Order: Ensure that the versions increment logically so that Packagist can sort them correctly.
Here is an example of how to version your releases:
-
Initial Development:
v0.0.1-alpha.1v0.0.1-alpha.2v0.0.1-beta.1v0.0.1-beta.2v0.0.1-rc.1(Release Candidate)v0.0.1
-
Subsequent Versions:
v0.1.0-alpha.1v0.1.0-beta.1v0.1.0v1.0.0-alpha.1v1.0.0-beta.1v1.0.0-rc.1v1.0.0
Using this approach, Packagist will list the versions correctly with the latest version at the top. Here is how the sorted order would look:
v1.0.0v1.0.0-rc.1v1.0.0-beta.1v1.0.0-alpha.1v0.1.0v0.1.0-beta.1v0.1.0-alpha.1v0.0.1v0.0.1-rc.1v0.0.1-beta.2v0.0.1-beta.1v0.0.1-alpha.2v0.0.1-alpha.1
By following this versioning scheme, you ensure that the latest version always appears at the top of the list in Packagist.