ocramius/package-versions
Fast, zero‑I/O access to Composer dependency versions at runtime. Reads version data compiled from composer.lock during install/update, so calls are cheap. Use PackageVersions\Versions::getVersion('vendor/package') to embed or log exact versions.
Architecture fit: This package integrates seamlessly with Laravel's Composer-based dependency management. It operates as a lightweight library (post-2.0.0) that generates static version metadata during composer install, avoiding runtime I/O. Laravel's standard production deployments always include composer.lock, making it a natural fit for version-dependent asset generation or runtime diagnostics without architecture conflicts.
Integration feasibility: High. Requires only composer require and follows Laravel's existing Composer workflow. The package's optimization recommendation (optimize-autoloader) aligns with Laravel's production best practices. No complex configuration or bootstrapping needed—simply call Versions::getVersion() where version data is required.
Technical risk: Low. The package has extensive testing (mutation coverage, type coverage), active maintenance (2.11.0 release in 2025), and resolved historical issues (e.g., Composer plugin conflicts fixed in 2.0.0). Primary risk is missing composer.lock in deployment (non-standard for Laravel), but this is a deployment failure rather than package flaw. PHP 8.1+ compatibility matches modern Laravel versions.
Key questions:
composer.lock is intentionally omitted (e.g., dynamic deployment scenarios)?composer install in Laravel-specific contexts (e.g., custom installer scripts)?Stack fit: Perfect alignment with Laravel's Composer-driven dependency management. The package operates entirely within Composer's lifecycle, leveraging composer.lock as its data source—exactly how Laravel manages dependencies. No framework-specific adjustments needed; it complements existing Laravel tooling (e.g., artisan commands, deployment scripts).
Migration path: Minimal. Add to composer.json and run composer update. Existing Laravel projects can adopt it incrementally—start with non-critical features (e.g., version-aware logging) before expanding to core functionality. The static class generation occurs automatically during install, requiring no code changes to existing Laravel services.
Compatibility: Fully compatible with Laravel 8+ (PHP 8.0+). The package supports PHP 8.1–8.5 (per 2.11.
How can I help you explore Laravel packages today?