PHP code example of jimchen / yii2-ranking

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

    

jimchen / yii2-ranking example snippets



[
	'components' => [
		'ranking' => [
			'class' => \jimchen\ranking\RankingManager::class,
			'name' => 'test',
			'redis' => 'redis',
			'fetchNum' => 10,
			'rankingClasses' => [
				\jimchen\ranking\ranking\MonthlyRanking::class,
			],
		],
	],
]



use jimchen\ranking\ranking\MonthlyRanking;

Yii::$app->ranking->import(new YourDataSource());

$monthlyRank = Yii::$app->ranking->get(MonthlyRanking::class);

$monthlyRank->rank('john'); // 获取john的排名
$monthlyRank->score('john'); // 获取john的分数
$monthlyRank->top(10); // 获取月榜分数最高的前10