PHP code example of xutl / yii2-ranking

1. Go to this page and download the library: Download xutl/yii2-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/ */

    

xutl / yii2-ranking example snippets


return [
    //....
    'components' => [
        'ranking' => [
           'class' => 'xutl\ranking\Client',
           'redis' => [
                'scheme' => 'tcp',
                'host' => '127.0.0.1',
                'port' => 6379,
                //'password' => '1984111a',
                'db' => 0
           ],
        ],
    ]
];

/** @var \xutl\ranking\Ranking $ranking */
$ranking = Yii::$app->ranking->getRankingRef('download');

$ranking->addScores(1, 2);
$ranking->addScores(2, 2);
$ranking->addScores(2, 2);
$ranking->addScores(1, 2);
$ranking->addScores(3, 2);
$ranking->addScores(3, 2);
$ranking->addScores(1, 2);
$ranking->addScores(5, 2);
$ranking->addScores(6, 2);
$ranking->addScores(7, 2);
$ranking->addScores(9, 2);
$ranking->addScores(1, 2);
$ranking->addScores(1, 2);
$rankings = $ranking->getCurrentMonthTop10(date('Ymd'), 0, 9);
print_r($rankings);
exit;