### Composer Installation Source: https://github.com/jean85/pretty-package-versions/blob/2.x/README.md Instructions for installing the pretty-package-versions library using Composer, both via the command line and directly in the composer.json file. ```bash composer require 'jean85/pretty-package-versions:^1.5 || ^2.0' ``` ```json { "require": { "jean85/pretty-package-versions": "^1.5 || ^2.0" } } ``` -------------------------------- ### PrettyVersions Usage Example Source: https://github.com/jean85/pretty-package-versions/blob/2.x/README.md Demonstrates how to use the `PrettyVersions::getVersion()` method to retrieve a `Version` object for a given package and access its various version-related methods. ```php 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' ``` -------------------------------- ### Version Class Method Updates (2.0) Source: https://github.com/jean85/pretty-package-versions/blob/2.x/README.md This section details the changes in the Version class methods starting from version 2.0. New methods with 'reference' in their names have been introduced to better align with data retrieved from the Composer 2 API. The old, deprecated methods are still available but are marked for removal in future versions. ```PHP Version::getReference() // Replaces Version::getCommitHash() Version::getShortReference() // Replaces Version::getShortCommitHash() Version::getVersionWithShortReference() // Replaces Version::getVersionWithShortCommit() ``` -------------------------------- ### Version Class Methods Source: https://github.com/jean85/pretty-package-versions/blob/2.x/README.md Details the public methods available on the `Jean85Version` class, explaining what each method returns, such as the pretty version, short version, reference, and more. ```APIDOC Jean85\Version: getPrettyVersion(): string Returns the short version if it's a tagged version, otherwise returns the result of getVersionWithShortCommit(). getShortVersion(): string Returns just the version of the package (e.g., '6.0.0', 'v.1.7.0', '99999-dev'). getReference(): string Returns the reference of the installed package, typically the full Git commit hash. getShortReference(): string Returns the shortened version of the reference (e.g., 'fa5711'). getVersionWithShortReference(): string Returns the package version followed by the short reference (e.g., '6.0.0@fa5711'). getPackageName(): string Returns the original package name. getFullVersion(): string Returns the same value as PackageVersions\Versions::getVersion(). __toString(): string Returns the same as getPrettyVersion(). ``` -------------------------------- ### Version 1.5+ Methods Source: https://github.com/jean85/pretty-package-versions/blob/2.x/README.md Introduces additional methods available since version 1.5, including `getRootPackageName` and `getRootPackageVersion` for accessing information about the root project. ```APIDOC PrettyVersions: getRootPackageName(): string Returns the package name of the current (root) project, equivalent to the 'name' property in composer.json. getRootPackageVersion(): string A shortcut to getVersion(PrettyVersions::getRootPackageName()). ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.