PHPackages                             tourze/user-id-idcard-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. [Validation &amp; Sanitization](/categories/validation)
4. /
5. tourze/user-id-idcard-bundle

ActiveSymfony-bundle[Validation &amp; Sanitization](/categories/validation)

tourze/user-id-idcard-bundle
============================

用户身份证验证模块，提供身份证号码的存储、验证和管理功能

0.0.1(7mo ago)00MITPHPCI passing

Since Nov 10Pushed 6mo ago1 watchersCompare

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

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

User ID Idcard Bundle
=====================

[](#user-id-idcard-bundle)

[![PHP Version](https://camo.githubusercontent.com/41dc8b7f19849bcbf6ee8879bd631fdfa56f6e3a9d101f410cc9b74ec5c6e068/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344382e312d3838393242462e7376673f7374796c653d666c6174)](https://php.net/)[![License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](LICENSE)[![Symfony](https://camo.githubusercontent.com/cc09ac1aaf371c7f0df1288581138b3a237486f556ae6e0ed50330da04188680/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f73796d666f6e792d253545362e342d677265656e2e737667)](https://symfony.com/)[![Build Status](https://github.com/tourze/php-monorepo/workflows/CI/badge.svg)](https://github.com/tourze/php-monorepo/actions)[![Coverage](https://camo.githubusercontent.com/2dcfe5c59200ab7211a68f50676988ab39ac6ca57bf255956dfc53202d4f2d1c/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f746f75727a652f7068702d6d6f6e6f7265706f3f666c61673d757365722d69642d6964636172642d62756e646c65267374796c653d666c61742d737175617265)](https://codecov.io/gh/tourze/php-monorepo)

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

A Symfony bundle that provides Chinese ID card identity verification functionality as an extension to the user identity system.

Features
--------

[](#features)

- Chinese ID card identity management
- Integration with user identity system
- Doctrine ORM entity for ID card storage
- Service decorator pattern for extensibility
- Snowflake ID generation support
- Timestamp and blame tracking

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

[](#installation)

```
composer require tourze/user-id-idcard-bundle
```

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

[](#requirements)

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

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

[](#dependencies)

- `tourze/user-id-bundle`: Base identity system
- `tourze/doctrine-snowflake-bundle`: Snowflake ID generation
- `tourze/doctrine-timestamp-bundle`: Timestamp tracking
- `tourze/doctrine-user-bundle`: User blame tracking

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

[](#quick-start)

### 1. Enable the Bundle

[](#1-enable-the-bundle)

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

```
return [
    // ... other bundles
    Tourze\UserIDIdcardBundle\UserIDIdcardBundle::class => ['all' => true],
];
```

### 2. Update Database Schema

[](#2-update-database-schema)

```
php bin/console doctrine:schema:update --force
```

### 3. Basic Usage

[](#3-basic-usage)

```
use Tourze\UserIDIdcardBundle\Entity\IdcardIdentity;
use Tourze\UserIDIdcardBundle\Service\UserIdentityIdcardService;

// Create ID card identity
$idcardIdentity = new IdcardIdentity();
$idcardIdentity->setIdcard('110101199001011234');
$idcardIdentity->setUser($user);

// Find by ID card number
$identity = $userIdentityService->findByType(
    IdcardIdentity::IDENTITY_TYPE,
    '110101199001011234'
);

// Get all identities for a user
$identities = $userIdentityService->findByUser($user);
```

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

[](#configuration)

This bundle extends the `tourze/user-id-bundle` and requires no additional configuration. It automatically decorates the `UserIdentityService` to handle ID card identities.

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

[](#advanced-usage)

### Custom Validation

[](#custom-validation)

You can extend the ID card validation by creating custom validators:

```
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;

class CustomIdcardValidator extends ConstraintValidator
{
    public function validate($value, Constraint $constraint): void
    {
        // Custom validation logic
        if (!$this->isValidIdcard($value)) {
            $this->context->buildViolation($constraint->message)
                ->addViolation();
        }
    }

    private function isValidIdcard(string $idcard): bool
    {
        // Implement your custom validation logic
        return true;
    }
}
```

### Service Integration

[](#service-integration)

```
use Tourze\UserIDIdcardBundle\Service\UserIdentityIdcardService;

class YourService
{
    public function __construct(
        private UserIdentityIdcardService $identityService
    ) {}

    public function processUserIdentity(UserInterface $user): void
    {
        $identities = $this->identityService->findByUser($user);
        foreach ($identities as $identity) {
            if ($identity->getIdentityType() === IdcardIdentity::IDENTITY_TYPE) {
                // Process ID card identity
            }
        }
    }
}
```

Entity Structure
----------------

[](#entity-structure)

The `IdcardIdentity` entity includes:

- `id`: Snowflake ID (primary key)
- `idcard`: Chinese ID card number (18 digits)
- `user`: Reference to user entity
- `createTime`: Creation timestamp
- `updateTime`: Last update timestamp
- `createBy`: User who created the record
- `updateBy`: User who last updated the record

License
-------

[](#license)

MIT

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance65

Regular maintenance activity

Popularity0

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity25

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

Unknown

Total

1

Last Release

236d 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-id-idcard-bundle/health.svg)

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

###  Alternatives

[easycorp/easyadmin-bundle

Admin generator for Symfony applications

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

The easy like Crud'it Bundle.

1616.4k14](/packages/2lenet-crudit-bundle)[open-dxp/opendxp

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

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

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

8.5k5.9M738](/packages/sylius-sylius)[oro/platform

Business Application Platform (BAP)

645143.5k115](/packages/oro-platform)[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)
