{"id":13462396,"url":"https://github.com/douyasi/identity-card","last_synced_at":"2026-02-08T22:35:44.911Z","repository":{"id":28248463,"uuid":"31754904","full_name":"douyasi/identity-card","owner":"douyasi","description":"Chinese Identity Card package （中国大陆）公民身份证类","archived":false,"fork":false,"pushed_at":"2023-04-27T03:43:14.000Z","size":3964,"stargazers_count":175,"open_issues_count":0,"forks_count":38,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-03-01T02:51:17.626Z","etag":null,"topics":["china-area","china-area-data","composer-packages","identity-card","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/douyasi.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-03-06T05:57:31.000Z","updated_at":"2024-09-29T01:57:48.000Z","dependencies_parsed_at":"2024-06-18T16:46:20.272Z","dependency_job_id":"9b42a0d0-03fd-4f79-990f-eba0854a59b0","html_url":"https://github.com/douyasi/identity-card","commit_stats":{"total_commits":77,"total_committers":4,"mean_commits":19.25,"dds":0.2597402597402597,"last_synced_commit":"fa8aee9f761d2b1b7cdd65db21501489c0ebec9b"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/douyasi%2Fidentity-card","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/douyasi%2Fidentity-card/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/douyasi%2Fidentity-card/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/douyasi%2Fidentity-card/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/douyasi","download_url":"https://codeload.github.com/douyasi/identity-card/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245382170,"owners_count":20606163,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["china-area","china-area-data","composer-packages","identity-card","php"],"created_at":"2024-07-31T12:00:46.957Z","updated_at":"2025-03-25T01:32:11.144Z","avatar_url":"https://github.com/douyasi.png","language":"PHP","funding_links":[],"categories":["Uncategorized"],"sub_categories":["Uncategorized"],"readme":"中国（大陆）公民身份证类\n------------------------\n\n\u003e   中国（大陆）公民身份证类包，数据来自国标 `GB/T 2260-2007` (中华人民共和国行政区划代码 标准) 。  \n\n[![Latest Stable Version](https://poser.pugx.org/douyasi/identity-card/v/stable.svg?format=flat-square)](https://packagist.org/packages/douyasi/identity-card)\n[![Latest Unstable Version](https://poser.pugx.org/douyasi/identity-card/v/unstable.svg?format=flat-square)](https://packagist.org/packages/douyasi/identity-card)\n[![License](https://poser.pugx.org/douyasi/identity-card/license?format=flat-square)](https://packagist.org/packages/douyasi/identity-card)\n[![Total Downloads](https://poser.pugx.org/douyasi/identity-card/downloads?format=flat-square)](https://packagist.org/packages/douyasi/identity-card)\n\n[ENGLISH README](readme_en.md)\n\n### 其它语言实现版本\n\n- [Node/Javascript 实现版本](https://github.com/ycrao/id.js)\n- [Rust 实现版本](https://github.com/ycrao/idrs)\n- 扩展与延伸：[省市县三级联动地址效果](https://raoyc.com/address-selector/)，使用的是最新 `2021` 年数据，需要做额外转换，转换好之后的 JS 文件大小约为 `99KB`，可以点 [此](https://raoyc.com/address-selector/divisions.js) 查看。\n\n### 版本更新记录\n\n- 2016年期间，发布 `1.0` - `1.2` 版本，数据来自 `GB/T 2260-2007` 标准，使用 `PHP` 内置数组存储。\n- 2017年05月26日，发布 `2.x` 系列初版 `2.0` 版本，开始使用 `SQLite` 作为数据存储源，并公布采集脚本。\n- 2017年09月，发布 `2.2` - `2.4` 版本，修复某些情况下返回地区（主要县级）信息为空、不准确的问题。\n- 2017年12月03日，发布 `2.4` 版本，修复返回错误星座问题。\n- 2018年03月27日，发布 `2.5` 版本，采集截止2018年01月的行政区划数据。\n- 2018年05月13日，发布 `2.6` 版本，更新其他语言实现，如 `Node/Javascript`·与 `Rust`。\n- 2019年03月31日，发布 `2.7` 版本，采集截止到2019年02月的行政区划数据，并修复错误年龄问题。下次（数据库）更新，预计在2020年03月底。\n- 2020年06月29日，发布 `2.8` 版本，采集截止到2020年02月（可能受疫情影响，民政部官网也只更新到该月份）的行政区划数据。\n- 2020年10月10日，发布 `2.9` 版本，采集截止到2020年08月的行政区划数据，同时移除采集脚本和历史归档数据（已剥离到 [china-divisions](https://github.com/douyasi/china-divisions) 新项目中），下次数据库与版本更新预计在2021年04月底。\n- 2023年02月08日，发布 `2.10` 版本，采集并人工处理截止到2021年的行政区划数据。一直未发布新版本，原因并不在作者我，民政部数据源头在最近2年多更新很不及时，参考此[说明](https://github.com/douyasi/china-divisions/tree/master/db)。\n\n### 安装说明\n\n在 `composer` 中添加依赖：\n\n```json\n    \"require\": {\n        \"douyasi/identity-card\": \"~2.0\"\n    }\n```\n\n然后在命令行窗体里执行 `composer update` 命令，或者参考下面直接使用 `composer require` 命令：\n\n```bash\ncd /path/to/your-project\ncomposer require \"douyasi/identity-card:~2.0\"\n```\n\n特别提示：\n\n本插件需要使用 `PDO` 连接 `sqlite` 数据库，故需要安装和开启 `pdo` 和 `pdo_sqlite` 组件。\n\n### 使用说明\n\n#### `Laravel` 示例代码\n\n创建ID类的实例，然后调用其对应方法。`Laravel` 测试路由示例：\n\n```php\nRoute::get('test', function() {\n    $ID = new Douyasi\\IdentityCard\\ID();\n    $pid = '42032319930606629x';\n    $passed = $ID-\u003evalidateIDCard($pid);\n    $area = $ID-\u003egetArea($pid);\n    $gender = $ID-\u003egetGender($pid);\n    $birthday = $ID-\u003egetBirth($pid);\n    $age = $ID-\u003egetAge($pid);\n    $constellation = $ID-\u003egetConstellation($pid);\n    return compact('passed', 'area', 'gender', 'birthday', 'age', 'constellation');\n});\n```\n\n#### 结果集\n\n上面测试路由将返回下面 `json` 数据响应：\n\n```json\n{\n    \"status\": true,\n    \"result\": {\n        \"is_pass\": true,\n        \"area\": {\n            \"status\": true,\n            \"result\": \"湖北省 十堰市竹山县\",\n            \"province\": \"湖北省\",\n            \"city\": \"十堰市\",\n            \"county\": \"竹山县\",\n            \"using\": 1\n        },\n        \"gender\": \"m\",\n        \"birthday\": \"1993-06-06\",\n        \"age\": 23,\n        \"constellation\": \"双子座\"\n    }\n}\n```\n\n\u003e   如果身份证证号校验通过，`passed` 返回 `true` ，否则返回 `false` 。其它字段（如 `eara` 、 `gender` 、 `birthday` 、 `age` 和 `constellation` ）顾名思义，就不做解释了。\n\n\u003e   `2.0+` 版本 `getArea()` 方法返回中新增 `using` 字段，表示行政区划代码当前是否还在使用中。如果为 `1` ，说明此身份证证号前6位数字代码（也就是行政区划代码，如 `420323` ）仍在使用，可以新签发（非续签非补办）此行政区划代码打头的身份证；为 `0` 表示行政区划已经发生变更（地名可能不变），不再新签发此行政区划代码打头的身份证。\n\n### API列表\n\n- `validateIDCard()` 获取身份证号码校验结果；\n- `getArea()` 获取身份证号码原始地区信息；\n- `getGender()` 获取性别，`m` 男性 `f` 女性；\n- `getBirth()` 获取出生年月日；\n- `getAge()` 获取年龄；\n- `getConstellation()` 获取星座。\n\n\u003e   关于星座月日范围，会有上下 `1-2` 天的浮动，这里以维基百科资料为主。\n\u003e   维基百科地址： https://zh.wikipedia.org/wiki/%E8%A5%BF%E6%B4%8B%E5%8D%A0%E6%98%9F%E8%A1%93 .\n\n```\n'水瓶座',  // 1.21-2.19 [Aquarius]\n'双鱼座',  // 2.20-3.20 [Pisces]\n'白羊座',  // 3.21-4.19 [Aries]\n'金牛座',  // 4.20-5.20 [Taurus]\n'双子座',  // 5.21-6.21 [Gemini]\n'巨蟹座',  // 6.22-7.22 [Cancer]\n'狮子座',  // 7.23-8.22 [Leo]\n'处女座',  // 8.23-9.22 [Virgo]\n'天秤座',  // 9.23-10.23 [Libra]\n'天蝎座',  // 10.24-11.21 [Scorpio]\n'射手座',  // 11.22-12.20 [Sagittarius]\n'魔羯座',  // 12.21-1.20 [Capricorn]\n```\n\n### 数据爬虫\n\n请参考 `china-divisions` 项目 `crawler` 目录下 [`readme`](https://github.com/douyasi/china-divisions/tree/master/crawler) 文件。\n\n### 参考资源\n\n- 中华人民共和国国家统计局 [行政区划代码](http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/)\n- 民政部 [县级以上行政区划变更情况](http://xzqh.mca.gov.cn/description?dcpid=1)\n- 民政部 [中华人民共和国行政区划代码](https://www.mca.gov.cn/article/sj/xzqh/1980/)\n\n### 特别致谢\n\n![JetBrains Logo (Main) logo](https://resources.jetbrains.com/storage/products/company/brand/logos/jb_beam.svg)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdouyasi%2Fidentity-card","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdouyasi%2Fidentity-card","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdouyasi%2Fidentity-card/lists"}