PHPackages                             particleacademy/laravel-fun-lab - 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. particleacademy/laravel-fun-lab

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

particleacademy/laravel-fun-lab
===============================

Analytics-driven gamification layer for Laravel applications. Track user engagement through awards, achievements, and prizes.

v0.3.1(3mo ago)382MITPHPPHP ^8.2

Since Dec 30Pushed 3mo agoCompare

[ Source](https://github.com/Particle-Academy/laravel-fun-labs)[ Packagist](https://packagist.org/packages/particleacademy/laravel-fun-lab)[ RSS](/packages/particleacademy-laravel-fun-lab/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (7)Versions (5)Used By (0)

Laravel Fun Lab
===============

[](#laravel-fun-lab)

[![Powered by Tynn](https://camo.githubusercontent.com/2057d8506d31b922175c18e91daef4650f2c0c117549bed35a77e8ecf82f0243/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f75726c3d687474707325334125324625324674796e6e2e61692532466f2532467061727469636c652d61636164656d792532466c61726176656c2d66756e2d6c616225324662616467652e6a736f6e)](https://tynn.ai/o/particle-academy/laravel-fun-lab)[![Latest Version](https://camo.githubusercontent.com/72e2df96a2a547cec98cbe17236d60026ee989f370f3c9e8d77a321d0b5c9acc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7061727469636c6561636164656d792f6c61726176656c2d66756e2d6c61622e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/particleacademy/laravel-fun-lab)[![License](https://camo.githubusercontent.com/fe1bb6508101eee5b52fd9e75f58ad79c7fd2a30d1fb45232495a88dda95d38b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7061727469636c6561636164656d792f6c61726176656c2d66756e2d6c61622e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/particleacademy/laravel-fun-lab)[![Laravel](https://camo.githubusercontent.com/2557965064af1e052691dbe4b1770d6922ce108fe1a70208b645a46b1af372fe/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d31312e7825323025374325323031322e782d7265642e7376673f7374796c653d666c61742d737175617265)](https://laravel.com)

> Analytics disguised as gamification — turn user activity into meaningful engagement insights.

Laravel Fun Lab (LFL) is an analytics-driven gamification layer for Laravel applications. Track user engagement through XP, achievements, and prizes while capturing structured activity data that apps normally never track.

Features
--------

[](#features)

- 🎯 **Event-Driven Architecture** - Every action, reward, or update is an observable event
- 🎮 **GamedMetrics XP System** - Create independent XP buckets with automatic level progression
- 📊 **MetricLevelGroups** - Combine multiple XP metrics with weights for composite leveling
- 🏆 **Achievements** - Define and grant achievements with auto-unlock on level-up
- 🎁 **Prizes** - Reward users with virtual or physical prizes
- 📈 **Built-in Analytics** - Query aggregate engagement data for behavioral insights
- 🔌 **Extensible** - Macros, hooks, and custom implementations
- ⚡ **Drop-In Simple** - Install → Track → Award workflow

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

[](#installation)

```
composer require particleacademy/laravel-fun-lab
php artisan lfl:install
```

Quick Start
-----------

[](#quick-start)

### 1. Add the Awardable Trait

[](#1-add-the-awardable-trait)

Add the `Awardable` trait to any model you want to gamify:

```
use LaravelFunLab\Traits\Awardable;

class User extends Authenticatable
{
    use Awardable;
}

// Works with any model!
class Team extends Model
{
    use Awardable;
}
```

The `Awardable` trait gives your model a **Profile** that tracks XP, achievements, and prizes.

### 2. Create GamedMetrics (XP Categories)

[](#2-create-gamedmetrics-xp-categories)

GamedMetrics are independent XP buckets. Each metric tracks its own XP and levels:

```
use LaravelFunLab\Facades\LFL;

// Create XP categories
LFL::setup(a: 'gamed-metric', with: ['slug' => 'combat-xp', 'name' => 'Combat XP']);
LFL::setup(a: 'gamed-metric', with: ['slug' => 'crafting-xp', 'name' => 'Crafting XP']);
LFL::setup(a: 'gamed-metric', with: ['slug' => 'social-xp', 'name' => 'Social XP']);
```

### 3. Define Levels for Metrics

[](#3-define-levels-for-metrics)

Levels are XP thresholds that can auto-unlock achievements:

```
// Define levels for combat-xp
LFL::setup(a: 'metric-level', with: ['metric' => 'combat-xp', 'level' => 1, 'xp' => 0, 'name' => 'Novice']);
LFL::setup(a: 'metric-level', with: ['metric' => 'combat-xp', 'level' => 2, 'xp' => 100, 'name' => 'Apprentice']);
LFL::setup(a: 'metric-level', with: ['metric' => 'combat-xp', 'level' => 3, 'xp' => 500, 'name' => 'Warrior']);
LFL::setup(a: 'metric-level', with: ['metric' => 'combat-xp', 'level' => 4, 'xp' => 1000, 'name' => 'Champion']);
```

### 4. Award XP

[](#4-award-xp)

Award XP using the fluent `award()` method:

```
// Award XP to a specific GamedMetric
LFL::award('combat-xp')
    ->to($user)
    ->amount(50)
    ->because('defeated boss')
    ->save();

// Check the profile
$profile = $user->getProfile();
echo $profile->total_xp; // Total XP across all metrics
```

### 5. Create and Grant Achievements

[](#5-create-and-grant-achievements)

```
// Create an achievement
LFL::setup(a: 'achievement', with: ['slug' => 'first-login', 'name' => 'First Login', 'description' => 'Welcome!', 'icon' => 'star']);

// Grant the achievement
LFL::grant('first-login')
    ->to($user)
    ->because('completed onboarding')
    ->save();

// Check if user has an achievement
if ($user->hasAchievement('first-login')) {
    // ...
}
```

### 6. Create and Grant Prizes

[](#6-create-and-grant-prizes)

```
// Create a prize
LFL::setup(
    a: 'prize',
    with: [
        'slug' => 'premium-access',
        'name' => '1 Month Premium Access',
        'type' => 'virtual',
        'inventory' => 100, // Limited quantity
    ]
);

// Grant the prize
LFL::grant('premium-access')
    ->to($user)
    ->because('won monthly contest')
    ->save();
```

### 7. Check Level Progress

[](#7-check-level-progress)

```
// Check if user has reached a specific level in a metric
if (LFL::hasLevel($user, 3, metric: 'combat-xp')) {
    echo "You're a Warrior!";
}

// Check level in a metric group
if (LFL::hasLevel($user, 10, group: 'overall-power')) {
    echo "You've reached Overall Power Level 10!";
}
```

### 8. Create Metric Level Groups

[](#8-create-metric-level-groups)

Combine multiple metrics with weights for composite leveling:

```
// Create a group
LFL::setup(a: 'metric-level-group', with: ['slug' => 'overall-power', 'name' => 'Overall Power']);

// Add metrics to the group with weights
LFL::setup(a: 'metric-level-group-metric', with: ['group' => 'overall-power', 'metric' => 'combat-xp', 'weight' => 1.0]);
LFL::setup(a: 'metric-level-group-metric', with: ['group' => 'overall-power', 'metric' => 'crafting-xp', 'weight' => 0.5]);

// Define levels for the group
LFL::setup(a: 'metric-level-group-level', with: ['group' => 'overall-power', 'level' => 1, 'xp' => 0, 'name' => 'Beginner']);
LFL::setup(a: 'metric-level-group-level', with: ['group' => 'overall-power', 'level' => 10, 'xp' => 5000, 'name' => 'Expert']);
```

### 9. Leaderboards

[](#9-leaderboards)

```
// Get top users by XP
$leaders = LFL::leaderboard()
    ->for(User::class)
    ->by('xp')
    ->take(10);
```

API Summary
-----------

[](#api-summary)

MethodPurpose`LFL::setup()`Create GamedMetrics, MetricLevels, MetricLevelGroups, Achievements, Prizes`LFL::award($metric)`Award XP to a GamedMetric (fluent builder)`LFL::grant($slug)`Grant an Achievement or Prize (fluent builder)`LFL::hasLevel($user, $level, metric: or group:)`Check if user has reached a level`LFL::profile($user)`Get the user's gamification profile`LFL::leaderboard()`Build leaderboard queries`LFL::analytics()`Build analytics queriesDocumentation
-------------

[](#documentation)

- **[Usage Guide](docs/usage.md)** - Examples and patterns
- **[API Reference](docs/api.md)** - Complete API documentation
- **[Configuration](docs/configuration.md)** - All configuration options

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

[](#requirements)

- PHP 8.2+
- Laravel 11.x or 12.x

License
-------

[](#license)

MIT License - see [LICENSE](LICENSE) for details.

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance78

Regular maintenance activity

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Every ~6 days

Total

4

Last Release

115d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3af1e64dc359664cd7a3cc9f6f4030ec8bce17d587eff9f41a7ca84cfda2285a?d=identicon)[wishborn](/maintainers/wishborn)

---

Top Contributors

[![wishborn](https://avatars.githubusercontent.com/u/461446?v=4)](https://github.com/wishborn "wishborn (14 commits)")

---

Tags

laravelanalyticsengagementGamificationachievementsawardsleaderboardsprizes

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/particleacademy-laravel-fun-lab/health.svg)

```
[![Health](https://phpackages.com/badges/particleacademy-laravel-fun-lab/health.svg)](https://phpackages.com/packages/particleacademy-laravel-fun-lab)
```

###  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)[psalm/plugin-laravel

Psalm plugin for Laravel

3274.9M308](/packages/psalm-plugin-laravel)[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k12.1M99](/packages/laravel-pulse)[spatie/laravel-enum

Laravel Enum support

3655.4M31](/packages/spatie-laravel-enum)[watson/validating

Eloquent model validating trait.

9723.3M47](/packages/watson-validating)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)

PHPackages © 2026

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