2017 © Pedro Peláez
 

library semantic-version

Tools for working with semantic version numbers.

image

ptlis/semantic-version

Tools for working with semantic version numbers.

  • Wednesday, April 26, 2017
  • by ptlis
  • Repository
  • 1 Watchers
  • 4 Stars
  • 210 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 13 Versions
  • 14 % Grown

The README.md

SemanticVersion

A modular, extensible library for PHP >= 5.6 providing APIs to support parsing & manipulation of semantic version numbers, comparators, ranges & collections., (*1)

The Semantic Versioning Specification describes the semantics and precedence rules used when parsing & manipulating version numbers etc., (*2)

Build Status Code Coverage Scrutinizer Code Quality Latest Stable Version, (*3)

Usage

Parse Version

First create an instance of the VersionEngine:, (*4)

    use ptlis\SemanticVersion\VersionEngine();

    $engine = new VersionEngine();

Then call the parseVersion method passing a version number:, (*5)

    $version = $engine->parseVersion('1.5.0-rc.1');

On failure to parse a \RuntimeException will be thrown., (*6)

Parse Version Range

Again, create an instance of the VersionEngine:, (*7)

    use ptlis\SemanticVersion\VersionEngine();

    $engine = new VersionEngine();

Then call the parseVersionRange method passing a version range:, (*8)

    $version = $engine->parseVersion('1.5.0-3.0.0');

As before, on failure to parse a \RuntimeException will be thrown., (*9)

Versions

The Version class provides a simple value type representing a semantic version number., (*10)

It provides simple accessors for the components of a semantic version number:, (*11)

    echo $version->getMajor();  // '1'
    echo $version->getMinor();  // '5'
    echo $version->getPatch();  // '0'
    echo $version->getLabel();  // 'rc.1'

A __toString implementation:, (*12)

    echo $version;  // '1.5.0-rc.1'

Version also implement SatisfiedByVersionInterface so offer the isSatisfiedBy method which returns true if the versions match., (*13)

Version Ranges

Version ranges are bundles of objects representing a version range constraint, represented by classes implementing VersionRangeInterface., (*14)

The simplest version range is a version and a comparator (e.g. >=2.5.3, '<1.0.0'), which is expressed by the ComparatorVersion class., (*15)

A more complex range would be one with an upper and lower bound (e.g. ~1.0.0, '^1.0.0', '>=1.0.0,<2.0.0' which are all equivalent). This is expressed via the LogicalAnd class wrapping two ComparatorVersion instances., (*16)

The most complex constraint would be one containing two ranges (e.g. 1.2.5-2.3.2|^4.0.0). This is expressed via Wrapping the two classes implementing VersionRangeInterface., (*17)

As VersionRangeInterface extends SatisfiedByVersionInterface these implement the isSatisfiedBy method which returns true if the passed version satisfies the constraint., (*18)

Known limitations

There currently are a few areas where this library deviates from the specification when dealing with labels & build metadata; this is to due to how the parsing of version-ranges is handled. However, having tested the parsing code against the complete list of packages scraped from packagist I found no packages affected by this., (*19)

Example semantic versions which are valid but the library is unable to parse:, (*20)

  • 1.0.0-0.3.7
  • 1.0.0-beta-17

The Versions

26/04 2017

dev-master

9999999-dev

Tools for working with semantic version numbers.

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

version semantic versioning

26/04 2017

v0.11.0

0.11.0.0

Tools for working with semantic version numbers.

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

version semantic versioning

04/02 2017

v0.10.0

0.10.0.0

Tools for working with semantic version numbers.

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

version semantic versioning

02/02 2014

v0.9.0

0.9.0.0

Tools for working with semantic version numbers.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

version semantic versioning

25/01 2014

v0.8.0

0.8.0.0

Tools for working with semantic version numbers.

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

version semantic versioning

18/01 2014

v0.7.0

0.7.0.0

Tools for working with semantic version numbers.

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

version semantic versioning

09/01 2014

v0.6.0

0.6.0.0

Tools for working with semantic version numbers.

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

version semantic versioning

09/01 2014

v0.5.1

0.5.1.0

Tools for working with semantic version numbers.

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

version semantic versioning

09/01 2014

v0.5.0

0.5.0.0

Tools for working with semantic version numbers.

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

version semantic versioning

09/01 2014

v0.4.0

0.4.0.0

Tools for working with semantic version numbers.

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

version semantic versioning

09/01 2014

v0.3.0

0.3.0.0

Tools for working with semantic version numbers.

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

version semantic versioning

01/01 2014

v0.2.0

0.2.0.0

Tools for working with semantic version numbers.

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

version semantic versioning

01/01 2014

v0.1.0

0.1.0.0

Tools for working with semantic version numbers.

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

version semantic versioning