2017 © Pedro Peláez
 

library pretty-package-versions

A wrapper for ocramius/package-versions to get pretty versions strings

image

jean85/pretty-package-versions

A wrapper for ocramius/package-versions to get pretty versions strings

  • Wednesday, June 13, 2018
  • by Jean85
  • Repository
  • 2 Watchers
  • 146 Stars
  • 1,183,779 Installations
  • PHP
  • 18 Dependents
  • 1 Suggesters
  • 5 Forks
  • 0 Open issues
  • 7 Versions
  • 44 % Grown

The README.md

jean85/pretty-package-versions

PHP Version Stable release Unstable release, (*1)

Build status Codecov, (*2)

A small, independent wrapper to get pretty versions strings of your dependencies., (*3)

Installation

*It's suggested to use this package with a constraint of ^1.5 || ^2.0, to obtain all the functionalities and guarantee future compatibility with Composer 2., (*4)

To install, use Composer:, (*5)

  • 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

This package was born as a thin wrapper for 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:, (*6)

pretty-package-versions Composer Dependency used
Up to 1.2 1.x only ocramius/package-versions
1.3 Both 1.x and 2.x composer/package-versions-deprecated, fork of ocramius/package-versions
1.4 2.x only None
1.5+ Both 1.x and 2.x composer/package-versions-deprecated, fork of ocramius/package-versions
2.0 (unreleased) 2.x only None

This 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 and related issues., (*7)

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:, (*8)

use Jean85\PrettyVersions;

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

$version = PrettyVersions::getVersion('roave/security-advisories');
$version->getPrettyVersion(); // 'dev-master@7cd88c8'
$version->getShortVersion(); // 'dev-master'
$version->getVersionWithShortCommit(); // '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., (*9)

Available methods

The Jean85\Version class has these public methods available:, (*10)

  • 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(), (*11)

  • getShortVersion(): string: it will return just the version of the package (i.e. 6.0.0, v.1.7.0, 99999-dev etc...), (*12)

  • getVersionWithShortCommit(): string: it will return the version of the package, followed by the short version of the commit hash (i.e. 6.0.0@fa5711), (*13)

  • getPackageName(): string will return the original package name, (*14)

  • getFullVersion(): string will return the same value as PackageVersions\Versions::getVersion(), (*15)

  • getCommitHash(): string will return the full commit hash, (*16)

  • getShortCommitHash(): string will return the short commit hash (i.e. fa5711), (*17)

  • __toString(): string will return the same as getPrettyVersion(), (*18)

Since 1.5

Since the 1.5 release, there are two additional methods available:, (*19)

  • 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())

The Versions

13/06 2018

dev-master

9999999-dev

A wrapper for ocramius/package-versions to get pretty versions strings

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alessandro Lai

composer package release versions package versions

13/06 2018

1.2

1.2.0.0

A wrapper for ocramius/package-versions to get pretty versions strings

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alessandro Lai

composer package release versions

21/01 2018

1.1

1.1.0.0

A wrapper for ocramius/pretty-package-versions to get pretty versions strings

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alessandro Lai

composer package release versions

30/11 2017

1.0.3

1.0.3.0

A wrapper for ocramius/pretty-package-versions to get pretty versions strings

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alessandro Lai

package versions

06/09 2017

1.0.2

1.0.2.0

A wrapper for ocramius/pretty-package-versions to get pretty versions strings

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alessandro Lai

package versions

06/07 2017

1.0.1

1.0.1.0

A wrapper for ocramius/pretty-package-versions to get pretty versions strings

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alessandro Lai

phpunit testing parallel test

06/07 2017

1.0

1.0.0.0

A wrapper for ocramius/pretty-package-versions to get pretty versions strings

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alessandro Lai

phpunit testing parallel test