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

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

particle-academy/laravel-fun-lab
================================

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

v0.4.2(1w ago)839↓21.1%2MITPHPPHP ^8.2

Since Dec 30Pushed 1w agoCompare

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

READMEChangelogDependencies (11)Versions (8)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/275af0dba8744a5b0e3083366258def6218675fb8e9c8fe421accfb30bbc417a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7061727469636c652d61636164656d792f6c61726176656c2d66756e2d6c61622e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/particle-academy/laravel-fun-lab)[![License](https://camo.githubusercontent.com/5cd6965ff94a41f865b43d4bf2800715fd5167d2f1b726074afdd4d0a7e16cc4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7061727469636c652d61636164656d792f6c61726176656c2d66756e2d6c61622e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/particle-academy/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 particle-academy/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)** - PHP facade + REST API documentation
- **[React / SPA Integration](docs/react.md)** - Auth contract, CORS, Echo, typed clients
- **[Broadcasting](docs/broadcasting.md)** - Real-time event channels and payloads
- **[Configuration](docs/configuration.md)** - All configuration options
- **[Extending](docs/extending.md)** - Custom implementations and hooks

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

[](#requirements)

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

License
-------

[](#license)

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

###  Health Score

44

—

FairBetter than 90% of packages

Maintenance98

Actively maintained with recent releases

Popularity18

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity42

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 ~25 days

Recently: every ~33 days

Total

7

Last Release

13d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/461446?v=4)[Wish Born](/maintainers/wishborn)[@wishborn](https://github.com/wishborn)

---

Top Contributors

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

---

Tags

laravelanalyticsengagementGamificationachievementsawardsleaderboardsprizes

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

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

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3325.1M337](/packages/psalm-plugin-laravel)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9732.3M121](/packages/roots-acorn)[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

76318.2M110](/packages/laravel-mcp)[laravel/pulse

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

1.7k14.1M120](/packages/laravel-pulse)[api-platform/laravel

API Platform support for Laravel

59156.3k10](/packages/api-platform-laravel)[flarum/core

Delightfully simple forum software.

261.4M2.2k](/packages/flarum-core)

PHPackages © 2026

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