1. Go to this page and download the library: Download redis/ranking 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/ */
redis / ranking example snippets
use Matsubo\Redis\ExpireMode;
use Matsubo\Redis\Ranking;
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
$ranking = new Ranking('season-1', $redis);
$ranking->setUserScore('kanako', 10); // true: added
$ranking->setUserScore('ayaka', 50);
$ranking->incrementScore('kanako', 5); // 15.0
$ranking->getScore('ayaka'); // 50.0
$ranking->getScore('nobody'); // null
$ranking->getRevRank('ayaka'); // 0 (top)
$ranking->getRevRangeWithScores(0, 9); // top 10: ['ayaka' => 50.0, 'kanako' => 15.0]
$ranking->expire(24 * 60 * 60 * 1000, ExpireMode::IfNone); // a daily board
docker compose run --rm php check # PHP-CS-Fixer (PER-CS 3.0), PHPStan (max), PHPUnit on PHP 8.3
docker compose run --rm php fix # apply the formatter
docker compose run --rm php84 test # PHPUnit on PHP 8.4
docker compose run --rm php85 test # PHPUnit on PHP 8.5
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.