PHPackages                             canerdogan/laravel-leaderboard - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. canerdogan/laravel-leaderboard

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

canerdogan/laravel-leaderboard
==============================

Laravel leaderbord module that besides the all-time leaderboard supports also periodic leaderboards: daily, weekly, monthly options backed by Redis.

v1.0(6y ago)415MITPHPPHP ^7.1CI failing

Since Apr 3Pushed 1y ago1 watchersCompare

[ Source](https://github.com/canerdogan/laravel-leaderboard)[ Packagist](https://packagist.org/packages/canerdogan/laravel-leaderboard)[ Docs](https://github.com/canerdogan/laravel-leaderboard)[ RSS](/packages/canerdogan-laravel-leaderboard/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)Dependencies (7)Versions (2)Used By (0)

Laravel Leaderboard
===================

[](#laravel-leaderboard)

[![Latest Version on Packagist](https://camo.githubusercontent.com/103f6ffc609d81bc9f147f247a49aa7a6bb2098477530f7a7c2575bb4e3fbdcb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f63616e6572646f67616e2f6c61726176656c2d6c6561646572626f6172642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/canerdogan/laravel-leaderboard)[![Total Downloads](https://camo.githubusercontent.com/4f0dd218ed3974bbe59f8e9baf597a467e82eb4e5da030120b6f35b41db6d21c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f63616e6572646f67616e2f6c61726176656c2d6c6561646572626f6172642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/canerdogan/laravel-leaderboard)

Laravel leaderboard module that supports both all-time leaderboards and periodic leaderboards (daily, weekly, monthly) backed by Redis.

Requirements
------------

[](#requirements)

- PHP 8.1 or higher
- Laravel 10.x, 11.x, or 12.x
- Redis server

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require canerdogan/laravel-leaderboard
```

The package will automatically register its service provider.

Configuration
-------------

[](#configuration)

This package requires Redis to be configured in your Laravel application. Make sure you have the Redis configuration set up in your `config/database.php` file:

```
'redis' => [
    'client' => env('REDIS_CLIENT', 'predis'),
    'default' => [
        'host' => env('REDIS_HOST', '127.0.0.1'),
        'password' => env('REDIS_PASSWORD', null),
        'port' => env('REDIS_PORT', 6379),
        'database' => env('REDIS_DB', 0),
    ],
],
```

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

```
use CanErdogan\Leaderboard\Facades\Leaderboard;

// Insert a score for a user
Leaderboard::insertScore('user123', 100, [
    'featureId' => 'game1',
    'scoreData' => [
        'level' => 5,
        'time' => 120,
        'bonus' => 20
    ]
]);

// Get the all-time leaderboard
$leaders = Leaderboard::getLeaderboard([
    'featureId' => 'game1',
    'fromRank' => 0,
    'toRank' => 9 // Top 10 players
]);

// Get a user's best score
$score = Leaderboard::getUserBestScore('user123', [
    'featureId' => 'game1'
], [
    'rawscore' => true,
    'scoreData' => true,
    'date' => true
]);

// Get a user's rank
$rank = Leaderboard::getRank('user123', [
    'featureId' => 'game1'
]);

// Get leaderboard around a specific user
$aroundMe = Leaderboard::getAroundMeLeaderboard('user123', [
    'featureId' => 'game1',
    'range' => 5 // 5 players above and below
]);
```

### Periodic Leaderboards

[](#periodic-leaderboards)

The package supports daily, weekly, and monthly leaderboards. You need to enable them first:

```
// Enable periodic leaderboards
Leaderboard::addLeaderboards([
    'daily' => true,
    'weekly' => true,
    'monthly' => true
]);

// Get the daily leaderboard
$dailyLeaders = Leaderboard::getLeaderboard([
    'leaderboard' => 'daily',
    'featureId' => 'game1',
    'fromRank' => 0,
    'toRank' => 9
]);

// Get the weekly leaderboard
$weeklyLeaders = Leaderboard::getLeaderboard([
    'leaderboard' => 'weekly',
    'featureId' => 'game1',
    'fromRank' => 0,
    'toRank' => 9
]);

// Get the monthly leaderboard
$monthlyLeaders = Leaderboard::getLeaderboard([
    'leaderboard' => 'monthly',
    'featureId' => 'game1',
    'fromRank' => 0,
    'toRank' => 9
]);
```

### Clearing Leaderboards

[](#clearing-leaderboards)

You can clear the leaderboards using the provided command:

```
php artisan leaderboard:clear
```

Or programmatically:

```
use CanErdogan\Leaderboard\RedisEndpoint;

$redisEndpoint = new RedisEndpoint();
$redisEndpoint->clearPeriodicalLeaderboard('daily');
$redisEndpoint->clearPeriodicalLeaderboard('weekly');
$redisEndpoint->clearPeriodicalLeaderboard('monthly');
```

### Standalone Usage

[](#standalone-usage)

You can also use the package without a full Laravel application. See the example in `examples/standalone.php`.

### Laravel Controller Example

[](#laravel-controller-example)

For a complete example of how to use the package in a Laravel controller, see the example in `examples/laravel-usage.php`.

Testing
-------

[](#testing)

```
composer test
```

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 68.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2231d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ee030ea353e879f8e20fdfb1ef38d9bb05e7f9dc862acdc44aa20e83182665c2?d=identicon)[canerdogan](/maintainers/canerdogan)

---

Top Contributors

[![canerdogan](https://avatars.githubusercontent.com/u/620056?v=4)](https://github.com/canerdogan "canerdogan (11 commits)")[![agentfarmx[bot]](https://avatars.githubusercontent.com/in/1138858?v=4)](https://github.com/agentfarmx[bot] "agentfarmx[bot] (5 commits)")

---

Tags

laravelrankingleaderboardlaravel-leaderboardcanerdogan

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/canerdogan-laravel-leaderboard/health.svg)

```
[![Health](https://phpackages.com/badges/canerdogan-laravel-leaderboard/health.svg)](https://phpackages.com/packages/canerdogan-laravel-leaderboard)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[interaction-design-foundation/laravel-geoip

Support for multiple Geographical Location services.

17221.0k3](/packages/interaction-design-foundation-laravel-geoip)[nedwors/navigator

A Laravel package to ease defining navigation menus

433.1k](/packages/nedwors-navigator)[dcblogdev/laravel-junie

Install pre-configured guides for Jetbrains Junie

392.5k](/packages/dcblogdev-laravel-junie)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
