PHPackages                             ofcold/identity-card - 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. ofcold/identity-card

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

ofcold/identity-card
====================

A simple proof of identity card of the people's Republic of China.

3.3.2(2y ago)18839.6k↓17.9%30[2 issues](https://github.com/ofcold/identity-card/issues)MITPHPPHP ^7.4|^8.0CI failing

Since Nov 19Pushed 2y ago4 watchersCompare

[ Source](https://github.com/ofcold/identity-card)[ Packagist](https://packagist.org/packages/ofcold/identity-card)[ Docs](https://ofcold.com)[ GitHub Sponsors](https://github.com/lilianjin)[ Fund](https://tidelift.com/funding/github/packagist/ofcold/identity-card)[ RSS](/packages/ofcold-identity-card/feed)WikiDiscussions 3.0 Synced 1mo ago

READMEChangelog (10)Dependencies (1)Versions (37)Used By (0)

[![](https://github.com/ofcold/identity-card/raw/2.0/id-card.svg?sanitize=true)](https://github.com/ofcold/identity-card/raw/2.0/id-card.svg?sanitize=true)

[![996.icu](https://camo.githubusercontent.com/f4f1d3401e1ad277cfc2cb1f0f50abdceccef3a91b3b40f1430dde88c06b43dc/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c696e6b2d3939362e6963752d7265642e7376673f7374796c653d666c61742d737175617265)](https://996.icu)[![LICENSE](https://camo.githubusercontent.com/1ce788414501ffd88188edc0263f9e3ec6ab32c7918df2c3302eadb9bb2b374c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d416e74692532303939362d626c75652e7376673f7374796c653d666c61742d737175617265)](https://github.com/996icu/996.ICU/blob/master/LICENSE)[![](https://camo.githubusercontent.com/4dfaa0d3519995e6ca03d5d0587ab733b9c676898b83b6ca066e5622bb8af97a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f6f66636f6c642f6964656e746974792d636172642e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/4dfaa0d3519995e6ca03d5d0587ab733b9c676898b83b6ca066e5622bb8af97a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f6f66636f6c642f6964656e746974792d636172642e7376673f7374796c653d666c61742d737175617265)[![Total Downloads](https://camo.githubusercontent.com/a8969876781fdccae2a858378703327e843391eb8b352a29fd573f13defe8f8a/68747470733a2f2f706f7365722e707567782e6f72672f6f66636f6c642f6964656e746974792d636172642f646f776e6c6f6164733f666f726d61743d666c61742d737175617265)](https://packagist.org/packages/ofcold/identity-card)

China (region) citizen ID card tool
-----------------------------------

[](#china-region-citizen-id-card-tool)

 [Simplified Chinese Documentation](https://github.com/ofcold/identity-card/blob/2.0/README_zh_CN.md)

> China (Mainland) ID card package, the data from the national standard `GB/T 2260-2007` [ (People's Republic of China administrative divisions code standard).](http://www.stats.gov.cn)

Other Language
--------------

[](#other-language)

- [.NET Rep](https://gitee.com/mick666/identity-card.NET)

Installing
----------

[](#installing)

```
    composer require ofcold/identity-card
```

Instructions
------------

[](#instructions)

A component based on People's Republic of China citizen ID card to obtain the user information.This works for any php framework, but only if the php version is greater than 7.1.

Useing
------

[](#useing)

### Useing in Laravel Validation

[](#useing-in-laravel-validation)

> Multi-language add `Please enter a valid Id Card` to your json language package.

```
use Ofcold\IdentityCard\Rules\IdCard;

/**
 * Get the validation rules that apply to the request.
 *
 * @return array
 */
public function rules()
{
    return [
        'id_card'  => [
            'required',
            new IdCard
        ]
    ];
}
```

#### Verify your Chinese ID card

[](#verify-your-chinese-id-card)

```
    // Result false OR Ofcold\IdentityCard\IdentityCard instance.
    $result = Ofcold\IdentityCard\IdentityCard::make('32010619831029081');

    if ( $result === false ) {

        return 'Your ID number is incorrect';
    }

    print_r($result->toArray());
```

#### OR test file.

[](#or-test-file)

```
    php test
```

```
$idCard = Ofcold\IdentityCard\IdentityCard::make('320106198310290811', 'en');
//  Use locale, Current supported zh-cn,en
// $idCard = Ofcold\IdentityCard\IdentityCard::make('320106198310290811', 'zh-cn');
if ( $idCard === false ) {

    return 'Your ID number is incorrect';
}
$area = $idCard->getArea();
$gender = $idCard->getGender();
$birthday = $idCard->getBirthday();
$age = $idCard->getAge();
$constellation = $idCard->getConstellation();
```

#### Results:

[](#results)

```
{
    "area": "shan xi sheng yun cheng di qu yun cheng shi",
    "province": "shan xi sheng",
    "city": "yun cheng di qu",
    "county": "yun cheng shi",
    "gender": "Male",
    "birthday": "1980-03-12",
    "zodiac": "Pig",
    "age": 38,
    "constellation": "Pisces"
}
```

### Api

[](#api)

- getArea() : string `Get Area`
- getConstellation() : string `Get constellation`
- getZodiac() : string `Get zodiac`
- getAge() : int `Get age`
- getBirthday(string $foramt = 'Y-m-d') : string `Get birthday`
- getGender() : string `Get gender`
- getCounty() : string|null `Get county`
- getCity() : string|null `Get city`
- getProvince() : string|null `Get province`
- toArray() : array `Get all information.`
- toJson(int $option) : string `Json format all information`
- \_\_get() : mixed
- \_\_toString() : toJson

CHANGELOG
---------

[](#changelog)

### V3.0.0

[](#v300)

- Added Laravel Rule.

### V2.0.0

[](#v200)

- Added [\#2](https://github.com/ofcold/identity-card/pull/2) \_\_get()
- Added [\#2](https://github.com/ofcold/identity-card/pull/2) \_\_toString()
- Modifed [\#2](https://github.com/ofcold/identity-card/pull/2) static make() Method returns the current object or boolean type
- Removed [\#2](https://github.com/ofcold/identity-card/pull/2) Construction method exception verification

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity46

Moderate usage in the ecosystem

Community19

Small or concentrated contributor base

Maturity80

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 93.9% 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 ~62 days

Recently: every ~250 days

Total

34

Last Release

1045d ago

Major Versions

1.2.x-dev → 2.0.02018-05-25

2.0.x-dev → 3.0.12019-04-13

PHP version history (3 changes)1.0.1PHP &gt;=7.1

3.2.0PHP &gt;=7.4

3.3.0PHP ^7.4|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/7c52a844b37ff37e8fa6d7bf4b482d8ff4ef15e250098d1f60bd19041d953834?d=identicon)[billwithjiali](/maintainers/billwithjiali)

---

Top Contributors

[![lilianjin](https://avatars.githubusercontent.com/u/21023027?v=4)](https://github.com/lilianjin "lilianjin (62 commits)")[![wacj1425](https://avatars.githubusercontent.com/u/3353551?v=4)](https://github.com/wacj1425 "wacj1425 (2 commits)")[![dchaofei](https://avatars.githubusercontent.com/u/29528188?v=4)](https://github.com/dchaofei "dchaofei (1 commits)")[![deMemory](https://avatars.githubusercontent.com/u/162716037?v=4)](https://github.com/deMemory "deMemory (1 commits)")

---

Tags

codeigniterfuelid-cardidcardidentitycardlaravelphalconphp71symfonythinkphpyiiregionareaID Cardphp7.xphp8.x

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ofcold-identity-card/health.svg)

```
[![Health](https://phpackages.com/badges/ofcold-identity-card/health.svg)](https://phpackages.com/packages/ofcold-identity-card)
```

###  Alternatives

[mjaschen/phpgeo

Simple Yet Powerful Geo Library

1.6k8.6M22](/packages/mjaschen-phpgeo)[cartalyst/converter

A framework agnostic measurement conversion and formatting package featuring multiple types of measurements and currency conversion.

88434.4k7](/packages/cartalyst-converter)[yupoxiong/region

ThinkPHP省市区(县)街道四级联动扩展

1032.9k1](/packages/yupoxiong-region)

PHPackages © 2026

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