PHPackages                             kennofizet/rewardplay-backend - 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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. kennofizet/rewardplay-backend

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

kennofizet/rewardplay-backend
=============================

RewardPlay backend package for Laravel - Token-based authentication system

0137PHP

Since Mar 11Pushed 3mo agoCompare

[ Source](https://github.com/kennofizet/rewardplay-backend)[ Packagist](https://packagist.org/packages/kennofizet/rewardplay-backend)[ RSS](/packages/kennofizet-rewardplay-backend/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

RewardPlay Backend
==================

[](#rewardplay-backend)

Laravel package that provides the **RewardPlay API**: user data, bag, shop, daily rewards, ranking, zones, and game settings. The frontend (`@kennofizet/rewardplay-frontend`) calls this API with a token.

---

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

[](#installation)

```
composer require kennofizet/rewardplay-backend
php artisan vendor:publish --tag=rewardplay-migrations
php artisan vendor:publish --tag=rewardplay-config
php artisan rewardplay:publish-images
php artisan rewardplay:export-constants
php artisan rewardplay:publish-constants
php artisan migrate
```

---

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

[](#configuration)

Use `config/rewardplay.php` or `.env`:

```
REWARDPLAY_IMAGES_FOLDER=rewardplay-images
REWARDPLAY_CONSTANTS_FOLDER=rewardplay-constants
REWARDPLAY_CUSTOM_GLOBAL_IMAGES_FOLDER=custom/global
REWARDPLAY_ALLOW_CORS_FOR_FILES=true
```

Core-related options (user table, API prefix, rate limit) live in **packages-core** config. After any config change:

```
php artisan config:clear
```

---

How the frontend connects
-------------------------

[](#how-the-frontend-connects)

The frontend needs **two** base URLs:

1. **coreUrl** — Your core API (e.g. `https://your-app.com/api/knf`). Used for auth check, player zones, managed zones, zone CRUD. Comes from **packages-core**.
2. **backendUrl** — RewardPlay API (e.g. `https://your-app.com/api/knf/rewardplay`). Used for user data, bag, shop, daily rewards, ranking, settings, manifest.

So in the host app you pass both when mounting RewardPlay (see frontend README).

---

Token (required by frontend)
----------------------------

[](#token-required-by-frontend)

Your app must issue a RewardPlay token for the logged-in user. The frontend sends it in the header `X-Knf-Token` on every request.

**Create or refresh token:**

```
use Kennofizet\RewardPlay\Services\TokenService;

$tokenService = app(TokenService::class);
$token = $tokenService->createOrRefreshToken($user->id);
```

Return this `$token` to the frontend (e.g. after login) so it can pass it to `RewardPlay` with `coreUrl` and `backendUrl`.

All RewardPlay API routes require a valid token; otherwise they return 401.

---

User model
----------

[](#user-model)

RewardPlay expects a **User** model (table from config, primary key `id`). To add token helpers to your User model, use the **HasKnfCoreToken** trait:

```
use Kennofizet\RewardPlay\Traits\HasKnfCoreToken;

class User extends Model
{
    use HasKnfCoreToken;
}
```

Then:

- `$user->getKnfCoreToken()` — existing token or create one
- `$user->refreshKnfCoreToken()` — create/refresh and return token

Use these in your login or “get game token” endpoint.

---

Artisan commands
----------------

[](#artisan-commands)

CommandDescription`rewardplay:export-constants`Export PHP constants to JS for frontend. Use `--output=/path` for custom path.`rewardplay:publish-constants`Copy constants JS to `public/{constants_folder}`. Use `--force` to overwrite.`rewardplay:publish-images`Copy default images to `public/{images_folder}`. Use `--force` to overwrite.`rewardplay:manage`Interactive CLI: server, zones, managers, fake data.`rewardplay:snapshot-ranking`Snapshot ranking (day/week/month/year). Use `--zone=1` for one zone. Schedule via cron.Typical flow for frontend constants:

```
php artisan rewardplay:export-constants
php artisan rewardplay:publish-constants
```

---

API overview (under your API prefix + `rewardplay`)
---------------------------------------------------

[](#api-overview-under-your-api-prefix--rewardplay)

- **Auth:** `GET /auth/user-data`
- **Player:** bag, shop, daily-rewards, events, custom-images
- **Ranking:** `GET /ranking`
- **Manifest:** `GET /manifest`
- **Settings (manager):** setting-items, setting-shop-items, setting-events, stack-bonuses, daily-rewards, level-exps, zones, options, item-sets, stats-transforms, stats

All routes require header `X-Knf-Token`.

---

Updating the package
--------------------

[](#updating-the-package)

After upgrading:

```
composer update kennofizet/rewardplay-backend
php artisan vendor:publish --tag=rewardplay-migrations --force
php artisan vendor:publish --tag=rewardplay-config --force
php artisan rewardplay:publish-images --force
php artisan rewardplay:export-constants
php artisan rewardplay:publish-constants --force
php artisan migrate
php artisan config:clear
php artisan cache:clear
```

###  Health Score

22

—

LowBetter than 21% of packages

Maintenance53

Moderate activity, may be stable

Popularity13

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity12

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/37218440?v=4)[kennofizet](/maintainers/kennofizet)[@kennofizet](https://github.com/kennofizet)

---

Top Contributors

[![phuongdpreg](https://avatars.githubusercontent.com/u/183365267?v=4)](https://github.com/phuongdpreg "phuongdpreg (56 commits)")

### Embed Badge

![Health badge](/badges/kennofizet-rewardplay-backend/health.svg)

```
[![Health](https://phpackages.com/badges/kennofizet-rewardplay-backend/health.svg)](https://phpackages.com/packages/kennofizet-rewardplay-backend)
```

###  Alternatives

[vitalybaev/laravel5-dkim

Laravel 5/6 package for signing outgoing messages with DKIM.

3163.1k](/packages/vitalybaev-laravel5-dkim)

PHPackages © 2026

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