Sometimes you need to check a Composer package’s version at runtime, e.g., for backward compatibility or feature flags.
Using InstalledVersions
Composer 2’s built-in InstalledVersions class can query the version of any installed package:
| |
References
- Composer Official Docs: InstalledVersions Runtime API β Complete method reference for the InstalledVersions class
- Composer GitHub Repository β Composer source code and changelog
- PHP Manual: Namespaces and use statements β PHP namespace fundamentals
