Check the installed RoadRunner version from PHP
The package finds out which RoadRunner version is installed and checks it against a version constraint, so an application or a library can fail early with a clear message instead of running against an incompatible server. RoadRunner 2.x, 2023.x–2025.x and 3.x are supported.
composer require roadrunner/version-checkerUse the RoadRunner\VersionChecker\VersionChecker methods to check the compatibility of the installed RoadRunner
version. The VersionChecker class has three public methods:
- greaterThan - Checks if the installed version of RoadRunner is greater than or equal to the specified version.
If no version is specified, the minimum required version will be determined based on the minimum required version of
the
spiral/roadrunnerpackage. - lessThan - Checks if the installed version of RoadRunner is less than or equal to the specified version.
- equal - Checks if the installed version of RoadRunner is equal to the specified version.
Versions are compared in RoadRunner release order: 2.x < 2023.x, 2024.x, 2025.x < 3.x.
For example, 3.0.0 satisfies greaterThan('2025.1'), and 2025.1.5 does not satisfy greaterThan('3.0').
All three methods throw an RoadRunner\VersionChecker\Exception\UnsupportedVersionException if the installed version
of RoadRunner does not meet the specified requirements. If RoadRunner is not installed, a
RoadRunner\VersionChecker\Exception\RoadrunnerNotInstalledException is thrown.
use RoadRunner\VersionChecker\VersionChecker;
use RoadRunner\VersionChecker\Exception\UnsupportedVersionException;
$checker = new VersionChecker();
try {
$checker->greaterThan('3.0');
} catch (UnsupportedVersionException $exception) {
var_dump($exception->getMessage()); // Installed RoadRunner version `2025.1.5` not supported. Requires version `3.0` or higher.
var_dump($exception->getInstalledVersion()); // 2025.1.5
var_dump($exception->getRequestedVersion()); // 3.0
}
try {
$checker->lessThan('2024.3');
} catch (UnsupportedVersionException $exception) {
var_dump($exception->getMessage()); // Installed RoadRunner version `2025.1.5` not supported. Requires version `2024.3` or lower.
var_dump($exception->getInstalledVersion()); // 2025.1.5
var_dump($exception->getRequestedVersion()); // 2024.3
}
try {
$checker->equal('3.0');
} catch (UnsupportedVersionException $exception) {
var_dump($exception->getMessage()); // Installed RoadRunner version `2025.1.5` not supported. Requires version `3.0`.
var_dump($exception->getInstalledVersion()); // 2025.1.5
var_dump($exception->getRequestedVersion()); // 3.0
}When the RR_VERSION environment variable is set, its value is used as the installed version. Otherwise the
checker runs ./rr --version from the current working directory. The detected version is cached for the lifetime of
the process.
To configure the VersionChecker to search for the RoadRunner binary in a location other than the default
(./rr), you can bind the RoadRunner\VersionChecker\Version\InstalledInterface
within application container using the RoadRunner\VersionChecker\Version\Installed class and passing the desired
file path as the $executablePath parameter. After that, you can retrieve the VersionChecker class from
application container.
Example with Spiral Framework container:
use RoadRunner\VersionChecker\Version\InstalledInterface;
use RoadRunner\VersionChecker\Version\Installed;
use RoadRunner\VersionChecker\VersionChecker;
$container->bindSingleton(InstalledInterface::class, new Installed(executablePath: 'some/path'));
$checker = $container->get(VersionChecker::class);Without a container, pass the instance directly:
$checker = new VersionChecker(new Installed(executablePath: 'some/path'));composer testcomposer psalmcomposer cs:diff