PHP code example of roadrunner-php / version-checker

1. Go to this page and download the library: Download roadrunner-php/version-checker library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

roadrunner-php / version-checker example snippets


use RoadRunner\VersionChecker\VersionChecker;
use RoadRunner\VersionChecker\Exception\UnsupportedVersionException;

$checker = new VersionChecker();

try {
    $checker->greaterThan('2023.1');
} catch (UnsupportedVersionException $exception) {
    var_dump($exception->getMessage()); // Installed RoadRunner version `2.12.3` not supported. Requires version `2023.1` or higher.
    var_dump($exception->getInstalledVersion()); // 2.12.3
    var_dump($exception->getRequestedVersion()); // 2023.1
}

try {
    $checker->lessThan('2.11');
} catch (UnsupportedVersionException $exception) {
    var_dump($exception->getMessage()); // Installed RoadRunner version `2.12.3` not supported. Requires version `2.11` or lower.
    var_dump($exception->getInstalledVersion()); // 2.12.3
    var_dump($exception->getRequestedVersion()); // 2.11
}

try {
    $checker->equal('2.11');
} catch (UnsupportedVersionException $exception) {
    var_dump($exception->getMessage()); // Installed RoadRunner version `2.12.3` not supported. Requires version `2.11`.
    var_dump($exception->getInstalledVersion()); // 2.12.3
    var_dump($exception->getRequestedVersion()); // 2.11
}

use RoadRunner\VersionChecker\Version\InstalledInterface;
use RoadRunner\VersionChecker\Version\Installed;

$container->bindSingleton(InstalledInterface::class, new Installed(executablePath: 'some/path'));
$checker = $container->get(VersionChecker::class);
bash
composer