PHPackages                             tourze/user-level-bundle - 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. tourze/user-level-bundle

ActiveSymfony-bundle[Utility &amp; Helpers](/categories/utility)

tourze/user-level-bundle
========================

用户等级管理模块，支持用户等级升降级记录和规则配置

0.1.0(6mo ago)00MITPHPCI passing

Since Nov 10Pushed 6mo ago1 watchersCompare

[ Source](https://github.com/tourze/user-level-bundle)[ Packagist](https://packagist.org/packages/tourze/user-level-bundle)[ RSS](/packages/tourze-user-level-bundle/feed)WikiDiscussions master Synced today

READMEChangelog (3)Dependencies (43)Versions (4)Used By (0)

User Level Bundle
=================

[](#user-level-bundle)

[![PHP Version](https://camo.githubusercontent.com/acffb6ae1962992d26e4466782832787e79504a6250f80d732c4283458b9f497/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e312d626c75652e737667)](https://www.php.net/)[![License](https://camo.githubusercontent.com/784362b26e4b3546254f1893e778ba64616e362bd6ac791991d2c9e880a3a64e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e2e737667)](LICENSE)[![Build Status](https://camo.githubusercontent.com/c27a457659b89ee4f1f80f7995c559dd37f2051bde7167ad25791e5c5c92cc8e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6275696c642d70617373696e672d627269676874677265656e2e737667)](https://github.com/tourze/php-monorepo)[![Code Coverage](https://camo.githubusercontent.com/bd63309fd9fa3c09fac5db30229dd07c09b001230f0b7fb62ec98dc91b2f7208/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f7665726167652d39302532352d627269676874677265656e2e737667)](https://github.com/tourze/php-monorepo)

[English](README.md) | [中文](README.zh-CN.md)

A Symfony bundle for managing user levels, upgrade rules, and level progression tracking.

Table of Contents
-----------------

[](#table-of-contents)

- [Features](#features)
- [Installation](#installation)
- [Configuration](#configuration)
- [Dependencies](#dependencies)
- [Usage](#usage)
- [Advanced Usage](#advanced-usage)
- [API Reference](#api-reference)
- [Testing](#testing)
- [Contributing](#contributing)
- [License](#license)

Features
--------

[](#features)

- **User Level Management**: Create and manage different user levels
- **Upgrade Rules**: Define rules for level progression with customizable criteria
- **Progress Tracking**: Monitor user upgrade progress with detailed analytics
- **Admin Interface**: JSON-RPC procedures for level administration and management
- **Doctrine Integration**: Full ORM support with optimized repositories
- **Validation**: Comprehensive entity validation using Symfony constraints
- **Extensible**: Easy to extend with custom upgrade logic and rules

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

[](#installation)

Install the bundle using Composer:

```
composer require tourze/user-level-bundle
```

Enable the bundle in your `config/bundles.php`:

```
return [
    // ...
    UserLevelBundle\UserLevelBundle::class => ['all' => true],
];
```

Update your database schema:

```
php bin/console doctrine:migrations:diff
php bin/console doctrine:migrations:migrate
```

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

[](#configuration)

The bundle works out of the box with minimal configuration. Service configuration is automatically loaded.

### Optional Configuration

[](#optional-configuration)

You can customize the bundle behavior in your `config/packages/user_level.yaml`:

```
# config/packages/user_level.yaml
user_level:
    # Configuration options will be added here as needed
```

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

1. **Create User Levels**:

```
use UserLevelBundle\Entity\Level;

$level = new Level();
$level->setTitle('Bronze');
$level->setLevel(1);
$level->setValid(true);
$entityManager->persist($level);
$entityManager->flush();
```

2. **Define Upgrade Rules**:

```
use UserLevelBundle\Entity\UpgradeRule;

$rule = new UpgradeRule();
$rule->setTitle('Points to Bronze');
$rule->setValue(100);
$rule->setLevel($level);
$rule->setValid(true);
$entityManager->persist($rule);
$entityManager->flush();
```

3. **Use the User Level Service**:

```
use UserLevelBundle\Service\UserLevelUpgradeService;

class UserController
{
    public function __construct(
        private readonly UserLevelUpgradeService $userLevelUpgradeService
    ) {
    }

    public function upgradeUser(UserInterface $user): void
    {
        $this->userLevelUpgradeService->upgrade($user);
    }
}
```

### Working with Repositories

[](#working-with-repositories)

```
use UserLevelBundle\Repository\LevelRepository;
use UserLevelBundle\Repository\UserLevelRelationRepository;

class UserLevelController
{
    public function __construct(
        private readonly LevelRepository $levelRepository,
        private readonly UserLevelRelationRepository $relationRepository
    ) {
    }

    public function getUserLevel(UserInterface $user): ?Level
    {
        $relation = $this->relationRepository->findOneBy(['user' => $user, 'valid' => true]);
        return $relation?->getLevel();
    }
}
```

Advanced Usage
--------------

[](#advanced-usage)

### Custom Upgrade Logic

[](#custom-upgrade-logic)

Extend the `UserLevelUpgradeService` to implement custom upgrade logic:

```
use UserLevelBundle\Service\UserLevelUpgradeService;

class CustomUpgradeService extends UserLevelUpgradeService
{
    public function checkCustomUpgradeConditions(UserInterface $user): bool
    {
        // Implement your custom logic here
        return true;
    }
}
```

### Admin Procedures

[](#admin-procedures)

The bundle provides JSON-RPC procedures for administration:

- `AdminCreateLevel`: Create new user levels
- `AdminUpdateLevel`: Update existing levels
- `AdminDeleteLevel`: Delete levels
- `AdminGetLevelList`: Get paginated list of levels
- `GetLevelLogsByBizUserId`: Get user level assignment logs

### Database Schema

[](#database-schema)

The bundle creates the following tables:

- `biz_user_level`: User levels configuration
- `biz_user_level_relation`: User-level relationships
- `biz_user_level_upgrade_rule`: Upgrade rules
- `biz_user_level_upgrade_progress`: User progress tracking
- `user_level_assign_log`: Level assignment history

API Reference
-------------

[](#api-reference)

### Entities

[](#entities)

- **Level**: Represents a user level with title and numeric value
- **UserLevelRelation**: Links users to their current levels
- **UpgradeRule**: Defines criteria for level progression
- **UpgradeProgress**: Tracks user progress towards next level
- **AssignLog**: Records level assignment history

### Services

[](#services)

- **UserLevelUpgradeService**: Core service for handling level upgrades

### Repositories

[](#repositories)

All entities have corresponding repositories with standard CRUD operations and custom query methods.

Testing
-------

[](#testing)

Run the test suite:

```
./vendor/bin/phpunit packages/user-level-bundle/tests
```

Run PHPStan analysis:

```
php -d memory_limit=2G ./vendor/bin/phpstan analyse packages/user-level-bundle
```

Contributing
------------

[](#contributing)

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

Please ensure all tests pass and follow the existing code style.

Dependencies
------------

[](#dependencies)

This bundle requires:

### System Requirements

[](#system-requirements)

- PHP 8.1 or higher
- Symfony 6.4+
- Doctrine ORM 3.0+

### Core Dependencies

[](#core-dependencies)

- `doctrine/collections`: ^2.3
- `doctrine/dbal`: ^4.0
- `doctrine/doctrine-bundle`: ^2.13
- `doctrine/orm`: ^3.0
- `symfony/config`: ^6.4
- `symfony/dependency-injection`: ^6.4
- `symfony/http-kernel`: ^6.4
- `symfony/security-core`: ^6.4
- `symfony/serializer`: ^6.4

### Tourze Bundle Dependencies

[](#tourze-bundle-dependencies)

- `tourze/arrayable`: 0.0.\*
- `tourze/bundle-dependency`: 0.0.\*
- `tourze/doctrine-snowflake-bundle`: 0.1.\*
- `tourze/doctrine-timestamp-bundle`: 0.0.\*
- `tourze/doctrine-track-bundle`: 0.1.\*
- `tourze/doctrine-user-bundle`: 0.0.\*
- `tourze/json-rpc-core`: 0.0.\*
- `tourze/json-rpc-log-bundle`: 0.1.\*
- `tourze/json-rpc-paginator-bundle`: 0.0.\*

For a complete list of dependencies, see [composer.json](composer.json).

License
-------

[](#license)

This bundle is released under the MIT license. See the [LICENSE](LICENSE) file for more information.

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance67

Regular maintenance activity

Popularity0

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity27

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.

###  Release Activity

Cadence

Every ~20 days

Total

3

Last Release

195d ago

### Community

Maintainers

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

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/tourze-user-level-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/tourze-user-level-bundle/health.svg)](https://phpackages.com/packages/tourze-user-level-bundle)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k5.9M738](/packages/sylius-sylius)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

9421.6k61](/packages/open-dxp-opendxp)[oro/platform

Business Application Platform (BAP)

645143.5k115](/packages/oro-platform)[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.9M386](/packages/easycorp-easyadmin-bundle)[2lenet/crudit-bundle

The easy like Crud'it Bundle.

1616.4k14](/packages/2lenet-crudit-bundle)[contao/core-bundle

Contao Open Source CMS

1231.6M2.8k](/packages/contao-core-bundle)

PHPackages © 2026

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