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:MAJOR
version increments for incompatible changes.MINOR
version increments for backward-compatible functionality.PATCH
version 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.1
v0.0.1-alpha.2
v0.0.1-beta.1
v0.0.1-beta.2
v0.0.1-rc.1
(Release Candidate)v0.0.1
-
Subsequent Versions:
v0.1.0-alpha.1
v0.1.0-beta.1
v0.1.0
v1.0.0-alpha.1
v1.0.0-beta.1
v1.0.0-rc.1
v1.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.0
v1.0.0-rc.1
v1.0.0-beta.1
v1.0.0-alpha.1
v0.1.0
v0.1.0-beta.1
v0.1.0-alpha.1
v0.0.1
v0.0.1-rc.1
v0.0.1-beta.2
v0.0.1-beta.1
v0.0.1-alpha.2
v0.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.