samsonasik/package-versions
PHP 5.6 backport of ocramius/package-versions offering fast, no-IO access to Composer dependency versions from composer.lock. Call Versions::getVersion(), getShortVersion(), or getMajorVersion() to retrieve installed package versions at runtime.
/health, /about, or admin-only diagnostics endpoint. When a customer files a bug, the first question is "which version of the library that owns this behavior are they on?" — this answers it deterministically from composer.lock instead of file scraping or guesswork.Versions class at install/update time; runtime lookups are static array reads). Buying costs one dependency; building costs a plugin, a lock-file parser, and a codegen step you must maintain through every Composer major. Build only if you need behavior it doesn't offer.getMajorVersion() is a cheap precondition check. This is a "fast fail with a clear message" feature, not a licensing or metering mechanism.Consider it only when all of the following hold:
composer.lock reads are unacceptable, or you need versions available in environments where the lock file isn't shipped.allow-plugins configuration — this is a Composer plugin, so install-time behavior depends on Composer's plugin API, and it predates Composer 2's plugin restrictions.composer install (not ship a stale generated file), and container image caching must not skip plugin execution.Look elsewhere — decisively — when:
Composer\InstalledVersions (runtime API, maintained, no plugin, no generated file). This is the correct answer for essentially every new project and should be the default recommendation.does installed 2.3.1 satisfy ^2.0?) rather than raw version strings — this gives you strings and a major number only.Recommended posture: treat as a frozen, vendored utility for legacy applications only. Do not introduce it into any codebase with a PHP upgrade path, and add "remove this dependency" to the same epic that tracks the PHP 8 migration.
To executives: This is a ~zero-cost utility that lets our applications report exactly which dependency versions they're running, so support can diagnose customer issues without a call. It is not a strategic bet and not a security or compliance control. The only reason it appears on our radar is that it's the last package that still works on PHP 5.6 — so adopting it is a marker of legacy debt, not a modernization. Approve it as a bridge; fund the PHP upgrade as the actual decision.
To engineering: samsonasik/package-versions is a PHP 5.6 backport of ocramius/package-versions. A Composer plugin parses composer.lock at install time and code-generates a static version map, so Versions::getVersion('vendor/pkg') and getMajorVersion() resolve with no runtime I/O. Use it for /health output, support diagnostics, and cache-key derivation. Three caveats we own: (1) last release 2016, no maintained upstream — we vendor or pin it and read the source; (2) it's a Composer plugin, so it interacts with Composer 2 plugin allowlists and must run in every composer install (don't commit the generated class as source of truth); (3) for any codebase on PHP 7.1+, the answer is Composer\InstalledVersions from Composer 2 — no plugin, no generated file, maintained. Ship it only where PHP 5.6 is genuinely unavoidable, and file the removal ticket the same day.
How can I help you explore Laravel packages today?