ocramius/package-versions
PackageVersions gives PHP applications fast, zero-I/O access to the installed versions of Composer dependencies. Version data is compiled from composer.lock at install time, so \PackageVersions\Versions::getVersion() returns a package's version and commit hash without any runtime disk reads—ideal fo...
X-App-Version response header, version-stamped cache-busting for compiled assets, and enriching error reports (Sentry/Bugsnag/CloudWatch) with dependency versions so a stack trace is self-describing.composer.lock per request.composer.lock and memoizes it is ~20 lines. The package wins on correctness (edge cases around composer install variants, classmap-authoritative mode, --no-scripts) and on the "zero I/O at call time" property, which removes it from the latency budget entirely. Caveat: Composer 2 ships its own runtime API (Composer\InstalledVersions, composer-runtime-api ^2.0) that overlaps with this package's core value. Before adopting, verify whether your Composer version already gives you this for free — if it does, the build-vs-buy decision may collapse to "buy nothing."Adopt when:
Look elsewhere (or build in-house) when:
Composer\InstalledVersions already covers your need — adding a dependency for equivalent functionality is pure surface-area cost.composer install --no-scripts or --classmap-authoritative; per the changelog these are supported but with degraded performance, which undercuts the main selling point.composer.lock (globally installed tools, non-Composer artifacts) or dynamic per-request resolution.composer require it on a Friday.Risk flags to record: single primary maintainer (bus factor), and a dataset showing zero dependents — likely a graph artifact, but worth a quick sanity check against Packagist before anyone cites it as a red flag.
For executives: "A small, mature, MIT-licensed utility that lets the application report exactly which dependency versions are running in any environment, with no performance cost. It doesn't change the product; it shortens incident triage and removes guesswork from releases. Cost: one dependency, one afternoon, zero infrastructure change. Downside risk: it's maintained by one person, it's a candidate for replacement by Composer's own built-in API, and it's easy to remove if either becomes a problem — the integration surface is a handful of call sites behind our own wrapper."
For engineering: "Use it as the source of truth for a /health or /version endpoint, response headers, and error-context enrichment. Wrap it in a single internal AppVersion facade so we can swap the implementation to Composer\InstalledVersions (or read the lockfile ourselves) without touching callers — that wrapper is the actual decision; the package underneath is reversible. Enable optimize-autoloader as the README recommends, confirm your composer install flags, and don't spread direct Versions::getVersion() calls across the codebase."
Decision requested: approve as a low-risk supporting dependency behind an abstraction, with a scheduled re-evaluation if Composer's native API fully covers us.
How can I help you explore Laravel packages today?