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

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

tourze/user-agreement-bundle
============================

用户协议管理，支持协议签署、撤销等功能的 Symfony Bundle

1.0.2(5mo ago)02MITPHPCI passing

Since Jun 14Pushed 4mo ago1 watchersCompare

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

READMEChangelog (4)Dependencies (54)Versions (5)Used By (0)

User Agreement Bundle
=====================

[](#user-agreement-bundle)

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

[![PHP Version](https://camo.githubusercontent.com/e364afc743a8cc2723cb4f6b885ea902332ff88a31a1455b7d06efe2f6e4e4cf/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f746f75727a652f757365722d61677265656d656e742d62756e646c652e737667)](https://packagist.org/packages/tourze/user-agreement-bundle)[![Latest Version](https://camo.githubusercontent.com/430a5d7c45d3ae96c5a0f962ff9e95c3f70d9198eb6b3a1210c0e83ffaec9bf5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f746f75727a652f757365722d61677265656d656e742d62756e646c652e737667)](https://packagist.org/packages/tourze/user-agreement-bundle)[![License](https://camo.githubusercontent.com/20efeb3d7dcd6efd9651086263a1f6291f099a03c3168591d565c5e98e23a017/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f746f75727a652f757365722d61677265656d656e742d62756e646c652e737667)](https://packagist.org/packages/tourze/user-agreement-bundle)[![Build Status](https://camo.githubusercontent.com/0a91d4823557f3f05123bc097f22e1b3a110c7acfdad427365014eccc0c43d88/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f746f75727a652f7068702d6d6f6e6f7265706f2f43492e737667)](https://github.com/tourze/php-monorepo/actions)[![Code Coverage](https://camo.githubusercontent.com/00868b24d394cf56df9dc7fe6026598f2e2702570548da56a19df835be6a958f/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f746f75727a652f7068702d6d6f6e6f7265706f2e737667)](https://codecov.io/gh/tourze/php-monorepo)[![Total Downloads](https://camo.githubusercontent.com/c4ee9ee5f5568c4c9a851030705d85f0457cc4b4d269c75d83df7d8ab71f9ffa/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f746f75727a652f757365722d61677265656d656e742d62756e646c652e737667)](https://packagist.org/packages/tourze/user-agreement-bundle)

A Symfony bundle for managing user agreements, protocols, and consent records. This bundle provides comprehensive functionality for handling user terms of service, privacy policies, and user account deletion requests in compliance with data protection regulations.

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

[](#table-of-contents)

- [Features](#features)
- [Installation](#installation)
- [Configuration](#configuration)
    - [Basic Configuration](#basic-configuration)
    - [Database Setup](#database-setup)
    - [Admin Interface](#admin-interface)
- [Quick Start](#quick-start)
    - [1. Create Protocol Entities](#1-create-protocol-entities)
    - [2. Record User Agreement](#2-record-user-agreement)
    - [3. Handle Deletion Requests](#3-handle-deletion-requests)
- [Advanced Usage](#advanced-usage)
    - [Custom Protocol Validation](#custom-protocol-validation)
    - [Event-Driven Architecture](#event-driven-architecture)
    - [Service Integration](#service-integration)
- [Protocol Types](#protocol-types)
- [Revocation Types](#revocation-types)
- [JSON-RPC API](#json-rpc-api)
- [Admin Interface](#admin-interface)
- [Compliance Features](#compliance-features)
- [Requirements](#requirements)
- [Contributing](#contributing)
- [License](#license)

Features
--------

[](#features)

- **Protocol Management**: Create and manage different types of user agreements (registration, usage, privacy, marketing)
- **Consent Tracking**: Record and track user agreement to protocols with IP tracking
- **Account Deletion**: Handle user account deletion requests with different revocation types
- **Admin Interface**: EasyAdmin integration for backend management
- **JSON-RPC API**: Programmatic access to agreement functionality
- **GDPR Compliance**: Built-in support for data protection requirements

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

[](#installation)

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

Add the bundle to your `config/bundles.php`:

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

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

[](#configuration)

### Basic Configuration

[](#basic-configuration)

Create `config/packages/user_agreement.yaml`:

```
user_agreement:
    enabled: true
    ip_tracking: true
    retention_period: 365  # days
```

### Database Setup

[](#database-setup)

Run the migrations to create required database tables:

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

### Admin Interface

[](#admin-interface)

Enable EasyAdmin integration in `config/packages/easy_admin.yaml`:

```
easy_admin:
    entities:
        ProtocolEntity:
            class: UserAgreementBundle\Entity\ProtocolEntity
        AgreeLog:
            class: UserAgreementBundle\Entity\AgreeLog
        RevokeRequest:
            class: UserAgreementBundle\Entity\RevokeRequest
```

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

[](#quick-start)

### 1. Create Protocol Entities

[](#1-create-protocol-entities)

```
use UserAgreementBundle\Entity\ProtocolEntity;
use UserAgreementBundle\Enum\ProtocolType;

$protocol = new ProtocolEntity();
$protocol->setType(ProtocolType::PRIVACY);
$protocol->setTitle('Privacy Policy');
$protocol->setVersion('1.0');
$protocol->setContent('Your privacy policy content...');
$protocol->setRequired(true);
$protocol->setEffectiveTime(new \DateTimeImmutable());

$entityManager->persist($protocol);
$entityManager->flush();
```

### 2. Record User Agreement

[](#2-record-user-agreement)

```
use UserAgreementBundle\Entity\AgreeLog;

$agreeLog = new AgreeLog();
$agreeLog->setMemberId($user->getId());
$agreeLog->setProtocolId($protocol->getId());
$agreeLog->setValid(true);

$entityManager->persist($agreeLog);
$entityManager->flush();
```

### 3. Handle Deletion Requests

[](#3-handle-deletion-requests)

```
use UserAgreementBundle\Entity\RevokeRequest;
use UserAgreementBundle\Enum\RevokeType;

$revokeRequest = new RevokeRequest();
$revokeRequest->setUser($user);
$revokeRequest->setType(RevokeType::All);
$revokeRequest->setRemark('User requested account deletion');

$entityManager->persist($revokeRequest);
$entityManager->flush();
```

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

[](#advanced-usage)

### Custom Protocol Validation

[](#custom-protocol-validation)

```
use Symfony\Component\Validator\Constraints as Assert;

#[Assert\Callback]
public function validateProtocol(ExecutionContextInterface $context): void
{
    if ($this->type === ProtocolType::PRIVACY && empty($this->content)) {
        $context->buildViolation('Privacy policy content is required')
            ->atPath('content')
            ->addViolation();
    }
}
```

### Event-Driven Architecture

[](#event-driven-architecture)

```
use UserAgreementBundle\Event\AgreeProtocolEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

class ProtocolSubscriber implements EventSubscriberInterface
{
    public static function getSubscribedEvents(): array
    {
        return [
            AgreeProtocolEvent::class => 'onProtocolAgreed',
        ];
    }

    public function onProtocolAgreed(AgreeProtocolEvent $event): void
    {
        // Custom logic when user agrees to protocol
        $protocol = $event->getProtocol();
        $user = $event->getUser();

        // Send confirmation email, log activity, etc.
    }
}
```

### Service Integration

[](#service-integration)

```
use UserAgreementBundle\Service\MemberService;

class MyService
{
    public function __construct(
        private MemberService $memberService,
    ) {}

    public function processUser(UserInterface $user): void
    {
        $memberId = $this->memberService->extractMemberId($user);
        // Process user agreement logic
    }
}
```

Protocol Types
--------------

[](#protocol-types)

- `MEMBER_REGISTER`: User registration agreement
- `MEMBER_USAGE`: User usage terms
- `PRIVACY`: Privacy policy
- `SALE_PUSH`: Marketing communications consent

Revocation Types
----------------

[](#revocation-types)

- `All`: Complete account deletion
- `NO_NOTIFY`: Keep profile but opt out of notifications
- `NOTIFY`: Keep profile and allow notifications

JSON-RPC API
------------

[](#json-rpc-api)

The bundle provides JSON-RPC procedures for external integration:

- `ApiAgreeSystemProtocol`: Record user agreement to protocols
- `ApiGetSystemProtocolContent`: Retrieve protocol content

Admin Interface
---------------

[](#admin-interface-1)

Access the admin interface through EasyAdmin:

- Protocol management: `/admin/protocol`
- Agreement logs: `/admin/agree-log`
- Deletion requests: `/admin/revoke-request`

Compliance Features
-------------------

[](#compliance-features)

- **IP Tracking**: Automatically records IP addresses for audit trails
- **Version Control**: Protocol versioning for regulatory compliance
- **Consent Records**: Immutable logs of user agreements
- **Data Retention**: Proper handling of user data deletion requests

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

[](#requirements)

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

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

[](#contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

33

—

LowBetter than 74% of packages

Maintenance77

Regular maintenance activity

Popularity2

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity39

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

Total

4

Last Release

173d ago

Major Versions

0.0.1 → 1.0.02025-11-05

### Community

Maintainers

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

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[sylius/sylius

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

8.4k5.6M647](/packages/sylius-sylius)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[contao/core-bundle

Contao Open Source CMS

1231.6M2.3k](/packages/contao-core-bundle)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[open-dxp/opendxp

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

7310.3k29](/packages/open-dxp-opendxp)

PHPackages © 2026

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