PHPackages                             jasmine/id-card-of-china - 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. jasmine/id-card-of-china

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

jasmine/id-card-of-china
========================

中华人民共和国身份证（The identity card of the people's Republic of China）

v1.2(7y ago)01751MITPHP

Since Nov 19Pushed 7y agoCompare

[ Source](https://github.com/Jasmine2/id-card-of-china)[ Packagist](https://packagist.org/packages/jasmine/id-card-of-china)[ RSS](/packages/jasmine-id-card-of-china/feed)WikiDiscussions master Synced 2mo ago

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

Identity Card Of China (PHP)
============================

[](#identity-card-of-china-php)

中华人民共和国身份证（The identity card of the people's Republic of China）

`id-card-of-china` 是一个基于「公民身份号码」规则获取公民身份号码中包含的基础信息组件。

安装
--

[](#安装)

- 你的 PHP 版本应该 `>= 7.0`

我们使用 Composer 安装：

```
composer require jasmine2/id-card-of-china
```

使用
--

[](#使用)

遵循 PHP-MD 原则，这个工具不提供静态调用，所以使用需要进行对象实例化：

```
use jasmine2\IdentityCard\China\Identity;

$peopleIDNumber = '350301198906180060';
$peopleIdentity = new Identity($peopleIDNumber);
```

APIs
----

[](#apis)

> 基于 `jasmine2\IdentityCard\China\IdentityInterface` 实例

- `legal`：检查公民身份号码是否合法
- `birthday`：获取公民身份号码中包含的生日信息
- `gender`：获取身份证包含的性别信息
- `region`: 获取身份证包含的地区信息，返回 `jasmine2\IdentityCard\China\Region\RegionInterface` 实例

### `region` 对象 APIs

[](#region-对象-apis)

- `code`： 获取 GB/T 2260 的地区行政代码
- `province`：获取省份名称或者直辖市名称
- `city`：获取城市名称，如果是直辖市则返回 `''`
- `county`：获取区县名称
- `tree`：获取地区层级数组
- `treeString`：获取地区完整字符串，支持传递一个参数作为省市区的分隔符

### 演示

[](#演示)

```
use jasmine2\IdentityCard\China\Identity;

$peopleIDNumber = '350302198906180060';
$peopleIdentity = new Identity($peopleIDNumber);
$peopleRegion = $peopleIdentity->region();

var_dump(
    $peopleIdentity->legal(),    // true | false
    $peopleIdentity->birthday(), // 1989-06-18
    $peopleIdentity->gender(),   // 女 | 男
    $peopleRegion->code(),       // 350302
    $peopleRegion->province(),   // 福建省
    $peopleRegion->city(),       // 莆田市
    $peopleRegion->county(),     // 城厢区
    $peopleRegion->tree(),       // ["福建省", "莆田市", "城厢区"]
    $peopleRegion->treeString(' ') // 福建省 莆田市 城厢区
);
```

致谢
--

[](#致谢)

>

该扩展对上面扩展使用的数据字典做了完善, 增加了行政区划变更前的数据.

LICENSE
-------

[](#license)

This component follows the MIT open source agreement.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity61

Established project with proven stability

 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

2732d ago

### Community

Maintainers

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

---

Top Contributors

[![YL20181120](https://avatars.githubusercontent.com/u/5860349?v=4)](https://github.com/YL20181120 "YL20181120 (6 commits)")

### Embed Badge

![Health badge](/badges/jasmine-id-card-of-china/health.svg)

```
[![Health](https://phpackages.com/badges/jasmine-id-card-of-china/health.svg)](https://phpackages.com/packages/jasmine-id-card-of-china)
```

PHPackages © 2026

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