composer/package-versions-deprecated
Composer addon that exposes installed package versions at runtime with no IO
Repository Health
Technical Analysis
composer/package-versions-deprecated is a Composer plugin that generates a class exposing the exact installed version of every package in a project, letting application code read those version numbers at runtime without any filesystem access. It is a fully-compatible fork of ocramius/package-versions that adds support for both Composer 1 and Composer 2 on PHP 7+.
The package is now end-of-life and deprecated: on Composer 2.x the same information is available from the built-in Composer\InstalledVersions class, and projects are encouraged to migrate to that instead. It remains widely installed as a transitive dependency, which is why it is documented here.
What You Get
- A generated Versions class listing every installed package and its version
- Runtime version lookups with no filesystem IO
- Compatibility with both Composer 1.x and 2.x on PHP 7+
- Drop-in replacement for ocramius/package-versions
- A simple static API returning a package’s exact resolved version
Common Use Cases
- Reading a dependency’s installed version from application code
- Bridging legacy code that requires ocramius/package-versions to Composer 2
- Displaying the running version of a library in diagnostics or headers
- Cache-busting or feature-gating based on an installed package version
Under The Hood
Architecture — The package registers as a Composer plugin that hooks into the dump-autoload / install lifecycle and writes a generated PHP class (PackageVersions\Versions) containing a compiled map of every installed package to its resolved version string. Because the data is baked into a class constant at install time, runtime lookups are simple array/constant reads with no I/O. The plugin logic detects whether it is running under Composer 1 or 2 and adapts accordingly, which is the primary value this fork adds over the original. Tech Stack — Pure PHP supporting 7 and 8, depending only on composer-plugin-api ^1.1 || ^2.0; development tooling includes PHPUnit, PHPCS, Psalm, and Infection (infection.json.dist) for mutation testing. Code Quality — Despite being small, the project carried strong quality tooling (static analysis via Psalm, coding standards via PHPCS, mutation testing via Infection); it is mature and stable but explicitly EOL, so no further development occurs. API Design — The consumer API is a single static call — Versions::getVersion(‘vendor/package’) returns the resolved version string — which is trivial to use; the main caveat is that the package is deprecated and the maintainers recommend migrating to Composer\InstalledVersions, which provides the same capability natively on Composer 2.