Search by

roadrunner / version-checker

roxblnfk

Checks that the installed RoadRunner binary matches the version required by the project's Composer packages

Package info

github.com/roadrunner-php/version-checker

Homepage

Issues

Chat

pkg:composer/roadrunner/version-checker

Fund package maintenance!

roadrunner-server

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 3

v1.4.0 2026-10-10 13:07 UTC

README

RoadRunner

Check the installed RoadRunner version from PHP

Documentation Sponsor

Psalm Level Type Coverage Mutation testing badge


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.

Get Started

Installation

composer require roadrunner/version-checker

PHP Latest Version on Packagist License Total Downloads

Usage

Use 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/roadrunner package.
  • 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
}

How the installed version is detected

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.

Path to the RoadRunner binary

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'));

Testing

composer test
composer psalm
composer cs:diff