Originally published at recca0120.github.io
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:
use Composer\InstalledVersions;
InstalledVersions::getVersion('laravel/framework');
Top comments (0)