承接 tourze/user-id-idcard-bundle 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

tourze/user-id-idcard-bundle

最新稳定版本:0.0.1

Composer 安装命令:

composer require tourze/user-id-idcard-bundle

包简介

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

README 文档

README

PHP Version License Symfony Build Status Coverage

English | 中文

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

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

composer require tourze/user-id-idcard-bundle

Requirements

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

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

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

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

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

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

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

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

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

MIT

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-11-10