PHPackages                             jean85/pretty-package-versions - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. jean85/pretty-package-versions

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

jean85/pretty-package-versions
==============================

A library to get pretty versions strings of installed dependencies

2.1.1(1y ago)1.3k289.5M↑10.7%1520MITPHPPHP ^7.4|^8.0CI passing

Since Jul 6Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/Jean85/pretty-package-versions)[ Packagist](https://packagist.org/packages/jean85/pretty-package-versions)[ RSS](/packages/jean85-pretty-package-versions/feed)WikiDiscussions 2.x Synced 1mo ago

READMEChangelog (10)Dependencies (7)Versions (25)Used By (20)

[![SWUbanner](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/banner2-direct.svg)](https://vshymanskyy.github.io/StandWithUkraine)

jean85/pretty-package-versions
==============================

[](#jean85pretty-package-versions)

[![PHP Version](https://camo.githubusercontent.com/e9e8e0d7fe224736a16127b260d383e131c5dfc4d7f9d702c43938ebe577029b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545372e31253743253545382e302d626c7565)](https://camo.githubusercontent.com/e9e8e0d7fe224736a16127b260d383e131c5dfc4d7f9d702c43938ebe577029b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545372e31253743253545382e302d626c7565)[![Stable release](https://camo.githubusercontent.com/7260332b82d2183d4f92c5d8b9942eae727f451ed8f2ca565d4e6eba6dd9e152/68747470733a2f2f706f7365722e707567782e6f72672f4a65616e38352f7072657474792d7061636b6167652d76657273696f6e732f76657273696f6e2e737667)](https://packagist.org/packages/Jean85/pretty-package-versions)[![Total Downloads](https://camo.githubusercontent.com/349ab2c329437ec635cb040e6cac936d6800087172bc73810168873f328695c9/68747470733a2f2f706f7365722e707567782e6f72672f6a65616e38352f7072657474792d7061636b6167652d76657273696f6e732f646f776e6c6f616473)](//packagist.org/packages/jean85/pretty-package-versions)

[![Build status](https://camo.githubusercontent.com/be22cb610f8d3ff7645c39b11144488eaa22bbaf475c4ed528f59c31467dfd16/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f4a65616e38352f7072657474792d7061636b6167652d76657273696f6e732f74657374732e79616d6c3f6272616e63683d322e78)](https://github.com/Jean85/pretty-package-versions/actions)[![Codecov](https://camo.githubusercontent.com/abcd861f8226be03614e5c65eafcd8d6411bdfe2c3583acdb23cd9f4b1adc1c7/68747470733a2f2f636f6465636f762e696f2f67682f4a65616e38352f7072657474792d7061636b6167652d76657273696f6e732f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/Jean85/pretty-package-versions)

A small, independent wrapper to get pretty versions strings of your dependencies.

Installation
------------

[](#installation)

- If you use this package in a library, you're encouraged to require it with a constraint of `^1.5 || ^2.0`, to obtain all the functionalities without constraining your end users to upgrade immediately to Composer 2.

To install, use Composer:

- from CLI: `composer require 'jean85/pretty-package-versions:^1.5 || ^2.0'`
- or, directly in your `composer.json`:

```
{
    "require": {
        "jean85/pretty-package-versions": "^1.5 || ^2.0"
    }
}
```

Compatibility
-------------

[](#compatibility)

This package was born as a thin wrapper for [ocramius/package-versions](https://packagist.org/packages/ocramius/package-versions); with the advent of Composer 2, this is no longer needed, since we can use directly `Composer\InstalledVersions`. This led to this version compatibility chart:

`pretty-package-versions`ComposerDependency usedUp to 1.21.x only`ocramius/package-versions`1.3Both 1.x and 2.x`composer/package-versions-deprecated`, fork of `ocramius/package-versions`1.42.x onlyNone1.5+Both 1.x and 2.x`composer/package-versions-deprecated`, fork of `ocramius/package-versions`2.02.x onlyNoneThis means that, with this package, you can obtain pretty versions without tying your user to any specific Composer version, with a smooth upgrade path. The release of 1.4 was reverted due to some discussion in [\#21](https://github.com/Jean85/pretty-package-versions/issues/21) and related issues.

Usage
-----

[](#usage)

This package should be used with a single class, `Jean85\PrettyVersions`: it provides a single method that returns a `Jean85\Version` object for the requested package, like in this example:

```
use Jean85\PrettyVersions;

$version = PrettyVersions::getVersion('phpunit/phpunit');
$version->getPrettyVersion(); // '6.0.0'
$version->getShortVersion(); // '6.0.0'
$version->getVersionWithShortReference(); // '6.0.0@fa5711'

$version = PrettyVersions::getVersion('roave/security-advisories');
$version->getPrettyVersion(); // 'dev-master@7cd88c8'
$version->getShortVersion(); // 'dev-master'
$version->getVersionWithShortReference(); // 'dev-master@7cd88c8'
```

The `Version` class has also a `__toString()` method implemented, so it can be easily cast to a string; the result would be the same as calling the `getPrettyVersion()` method.

### Available methods

[](#available-methods)

The `Jean85\Version` class has these public methods available:

- `getPrettyVersion(): string`: if the requested package is a tagged version, it will return just the short version; if not, it will output the same result as `getVersionWithShortCommit()`
- `getShortVersion(): string`: it will return just the version of the package (i.e. `6.0.0`, `v.1.7.0`, `99999-dev` etc...)
- `getReference(): string` will return the reference of the installed package, generally the full Git commit hash
- `getShortReference(): string` will return the shortened version of the reference (i.e. `fa5711`)
- `getVersionWithShortReference(): string`: it will return the version of the package, followed by the short version of the reference (i.e. `6.0.0@fa5711`)
- `getPackageName(): string` will return the original package name
- `getFullVersion(): string` will return the same value as `PackageVersions\Versions::getVersion()`
- `__toString(): string` will return the same as `getPrettyVersion()`

### Since 1.5

[](#since-15)

Since the 1.5 release, there are two additional methods available:

- `PrettyVersions::getRootPackageName` returns the package name of the current (root) project, so basically the `name` property value in your `composer.json`; it is a compatibility layer to be used in place of `PackageVersions\Versions::ROOT_PACKAGE_NAME`, which would be a transient dependency and it's not guaranteed to be present
- `PrettyVersions::getRootPackageVersion`, which is a shortcut to `PrettyVersions::getVersion(PrettyVersions::getRootPackageName())`

### Before 2.0

[](#before-20)

The methods with `reference` in the name were introduced in the 2.0 release, to better reflect the meaning of the data retrieved from Composer 2 API. The behavior is the same as the old methods, which are still present but deprecated:

New methodOld, deprecated method`Version::getReference()``Version::getCommitHash()``Version::getShortReference()``Version::getShortCommitHash()``Version::getVersionWithShortReference()``Version::getVersionWithShortCommit()`

###  Health Score

69

—

FairBetter than 100% of packages

Maintenance70

Regular maintenance activity

Popularity77

Solid adoption and visibility

Community36

Small or concentrated contributor base

Maturity78

Established project with proven stability

 Bus Factor1

Top contributor holds 84.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~151 days

Recently: every ~404 days

Total

22

Last Release

64d ago

Major Versions

1.5.1 → 2.0.02021-01-14

1.6.0 → 2.0.32021-02-22

PHP version history (4 changes)1.0PHP ^7.0

1.5.1PHP ^7.0|^8.0

2.0.0PHP ^7.1|^8.0

2.1.0PHP ^7.4|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/5cd2707d7bc5233dac66a38db2af69d347c4c815ffb6ddbd9be27cd1eda37d14?d=identicon)[Jean85](/maintainers/Jean85)

---

Top Contributors

[![Jean85](https://avatars.githubusercontent.com/u/6729988?v=4)](https://github.com/Jean85 "Jean85 (141 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (10 commits)")[![Chris53897](https://avatars.githubusercontent.com/u/7104259?v=4)](https://github.com/Chris53897 "Chris53897 (2 commits)")[![emodric](https://avatars.githubusercontent.com/u/362286?v=4)](https://github.com/emodric "emodric (2 commits)")[![villfa](https://avatars.githubusercontent.com/u/2891564?v=4)](https://github.com/villfa "villfa (2 commits)")[![VincentLanglet](https://avatars.githubusercontent.com/u/9052536?v=4)](https://github.com/VincentLanglet "VincentLanglet (1 commits)")[![garak](https://avatars.githubusercontent.com/u/179866?v=4)](https://github.com/garak "garak (1 commits)")[![Chris8934](https://avatars.githubusercontent.com/u/44963939?v=4)](https://github.com/Chris8934 "Chris8934 (1 commits)")[![jmsche](https://avatars.githubusercontent.com/u/3929498?v=4)](https://github.com/jmsche "jmsche (1 commits)")[![ostrolucky](https://avatars.githubusercontent.com/u/496233?v=4)](https://github.com/ostrolucky "ostrolucky (1 commits)")[![raphaelstolt](https://avatars.githubusercontent.com/u/48225?v=4)](https://github.com/raphaelstolt "raphaelstolt (1 commits)")[![TomasVotruba](https://avatars.githubusercontent.com/u/924196?v=4)](https://github.com/TomasVotruba "TomasVotruba (1 commits)")[![dereuromark](https://avatars.githubusercontent.com/u/39854?v=4)](https://github.com/dereuromark "dereuromark (1 commits)")[![DeyV](https://avatars.githubusercontent.com/u/311626?v=4)](https://github.com/DeyV "DeyV (1 commits)")

---

Tags

composerhacktoberfestocramiusphpversionswrappercomposerpackagereleaseversions

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Psalm, Rector

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/jean85-pretty-package-versions/health.svg)

```
[![Health](https://phpackages.com/badges/jean85-pretty-package-versions/health.svg)](https://phpackages.com/packages/jean85-pretty-package-versions)
```

###  Alternatives

[composer/satis

Simple Repository Generator

3.3k1.4M17](/packages/composer-satis)[fxp/composer-asset-plugin

NPM/Bower Dependency Manager for Composer

8894.8M41](/packages/fxp-composer-asset-plugin)[sllh/composer-versions-check

Checks if packages are up to date to last major versions after update

2352.4M16](/packages/sllh-composer-versions-check)[foxy/foxy

Fast, reliable, and secure NPM/Yarn/pnpm bridge for Composer

177287.5k25](/packages/foxy-foxy)[netojose/laravel-bootstrap-4-forms

Bootstrap 4 form builder for Laravel 5

182115.3k](/packages/netojose-laravel-bootstrap-4-forms)[cpx/cpx

Run any command from any composer package, even if it's not installed in your project.

40410.9k1](/packages/cpx-cpx)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
