PHPackages                             nabeghe/levex - 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. nabeghe/levex

ActiveLibrary

nabeghe/levex
=============

A simlpe leveling and experience (XP) system designed for PHP.

1.0.1(1y ago)44MITPHPPHP &gt;=7.4

Since Oct 14Pushed 10mo ago1 watchersCompare

[ Source](https://github.com/nabeghe/levex-php)[ Packagist](https://packagist.org/packages/nabeghe/levex)[ Docs](https://github.com/nabeghe/levex-php)[ RSS](/packages/nabeghe-levex/feed)WikiDiscussions master Synced 1mo ago

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

Levex (Level + Experience)
==========================

[](#levex-level--experience)

> A simple leveling and XP System for PHP, Just Like in Online Games.

Building a leveling system that showcases a user's level based on their experience points might seem like a daunting task. But fear not! Levex simplifies this process with just a few straightforward methods. You can effortlessly implement this functionality without diving into complex calculations. Enjoy a seamless experience as you elevate your users’ journey!

🫡 Usage
-------

[](#-usage)

### 🚀 Installation

[](#-installation)

You can install the package via composer:

```
composer require nabeghe/levex
```

### Instance

[](#instance)

#### Default Instance

[](#default-instance)

Retrieve a singleton instance with default options:

```
use Nabeghe\Levex\Levex;

$levex = Levex::instance();
```

#### Custom Instance

[](#custom-instance)

Retrieve a custom instance with custom options:

```
use Nabeghe\Levex\Levex;

$options = ['baseLevelXp' => 50];
$levex = new Levex($options);
```

Options are related to class fields:

NameDescription`baseLevelXp`XP required to reach level 1. Default `100`.`levelLogBase`Logarithmic base in calculating the level by XP. Default `3`.`priceXpRate`XP rate per unit of price. For example, if the rate is 10, every 10 units of a specified price will equal 1 XP. Default `1`.`godLevelSymbols`Symbols that indicate a level associated with the creator or God, rather than a regular level. Default `['∞']`.`negativeLevelIsGod`Indicates whether a negative level should be considered as the god/creator or not. Default `true`.`levelNamesHandler`A callable that acts as a replacement for the determineLevelName method and takes the same input. If determineLevelName returns null, the main method will be executed. Used to customize the name/title of levels. Default `null`.---

### Global Configuration

[](#global-configuration)

use kyeword `const` or function `define`.

NameDescription`LEVEX_BASE_LEVEL_XP`related to `$levex->baseLevelXp``LEVEX_LEVEL_LOG_BASE`related to `$levex->levelLogBase``LEVEX_PRICE_XP_RATE`related to `$levex->priceXpRate``LEVEX_GOD_LEVEL_SYMBOLS`related to `$levex->godLevelSymbols``LEVEX_NEGATIVE_LEVEL_IS_GOD`related to `$levex->negativeLevelIsGod`### Methods

[](#methods)

#### `calcLevel(int $xp): int`

[](#calclevelint-xp-int)

Calculates which level corresponds to a given XP.

#### `calcRequiredXpToLevel(int $level): int`

[](#calcrequiredxptolevelint-level-int)

Calculates the minimum XP required to reach a specified level.

#### `calcRemainingXpToLevel(int $level, $currentXP, &levelXP = null): int`

[](#calcremainingxptolevelint-level-currentxp-levelxp--null-int)

Calculates how much XP is remaining to reach a specific level.

**Notice:** The $levelXP is output of the calcRequiredXpToLevel()

#### `calcRemainingPercentToLevel(int $level, int $currentXP, int &$leftXP = 0): float|int`

[](#calcremainingpercenttolevelint-level-int-currentxp-int-leftxp--0-floatint)

Calculates how many percent of progress reamining to reaching a specific level.

**Notice:** The $levelXP is output of the remaining XP to reach the desired level.

#### `calcPassedPercentToLevel(int $level, int $currentXP, int &$leftXP = 0): float|int`

[](#calcpassedpercenttolevelint-level-int-currentxp-int-leftxp--0-floatint)

Calculates how many percent of progress has been made towards reaching a specific level.

**Notice:** The $levelXP is output of the remaining XP to reach the desired level.

#### `calcXpByPrice($price, ?float $rate = null): int`

[](#calcxpbypriceprice-float-rate--null-int)

Calculates how much XP can be earned from a given price.

Notice: The $rate is XP rate per unit of price. For example, if the rate is 10, every 10 units of a specified price will equal 1 XP. Default is option 'priceXpRate'.

#### `checkGodLevel($level): bool`

[](#checkgodlevellevel-bool)

Checks whether the level is specific to the god or not.

#### `determineLevelName($level): string`

[](#determinelevelnamelevel-string)

Retrives the name/title of a level.

📖 License
---------

[](#-license)

Licensed under the MIT license, see [LICENSE.md](LICENSE.md) for details.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance47

Moderate activity, may be stable

Popularity7

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

Total

2

Last Release

561d ago

### Community

Maintainers

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

---

Top Contributors

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

---

Tags

gamexplevel-uplevelexperiencelevexlevelingleveling systemxp systemExperience Points

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/nabeghe-levex/health.svg)

```
[![Health](https://phpackages.com/badges/nabeghe-levex/health.svg)](https://phpackages.com/packages/nabeghe-levex)
```

###  Alternatives

[hprose/hprose

It is a modern, lightweight, cross-language, cross-platform, object-oriented, high performance, remote dynamic communication middleware. It is not only easy to use, but powerful. You just need a little time to learn, then you can use it to easily construct cross language cross platform distributed application system.

2.1k215.3k37](/packages/hprose-hprose)[cjmellor/level-up

This package allows users to gain experience points (XP) and progress through levels by performing actions on your site. It can provide a simple way to track user progress and implement gamification elements into your application

66188.9k](/packages/cjmellor-level-up)[xp-framework/core

The XP framework is an all-purpose, object oriented PHP framework.

19536.2k102](/packages/xp-framework-core)

PHPackages © 2026

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