All Projects → alicfeng → Identitycard

alicfeng / Identitycard

Licence: mit
中国(大陆)公民身份证工具类🔨用于身份证计算年龄、生日、星座、性别、生肖、政区划代码,同时绘制身份证正反面

IdentityCard

中国(大陆)公民身份证类

Latest Stable Version Total Downloads License build status

安装

在项目composer.json添加依赖,如下:

"require": {
    "alicfeng/identity-card": "~3.1.0"
  }

或者直接通过CLI安装,如下:

composer require "alicfeng/identity-card" -vvv

使用

use AlicFeng\IdentityCard\InfoHelper;

$id = 'IdentityCard';

# 获取周岁 | 
$age = InfoHelper::identityCard()->age($id);

# 获取生日
$birthday = InfoHelper::identityCard()->birthday($id);

# 获取性别 | {男为M | 女为F}
$sex = InfoHelper::identityCard()->sex($id);

# 获取生肖
$constellation = InfoHelper::identityCard()->constellation($id);

# 获取星座
$star = InfoHelper::identityCard()->star($id);

# 获取星座
$star = InfoHelper::birthday()->star($birthday);

# 获取年龄
$age = InfoHelper::birthday()->age($id);

# 生成身份证正面
$front = InfoHelper::identityCard()->createFrontImage(...);

# 生成身份证反面
$back = InfoHelper::identityCard()->createBackImage(...);

# 获取省
$province = InfoHelper::identityCard()->province($id, $default='');

# 获取市
$city = InfoHelper::identityCard()->city($id, $default='');

# 获取区
$area = InfoHelper::identityCard()->area($id, $default='');

版本更新说明

  • V1.0

    在版本 1.0 中,证件号码错误都是返回false

  • V2.0

    在版本 2.0 中添加异常捕获机制,证件错误将返回异常,只有c::validate($id)方法返回bool值。

  • V2.3

    在版本 2.3 添加了一个新功能,可以提供身份证信息生成身份证图片。

    注意:图片的大小为:865 * 540 px

  • V3.0 - 2019.06.25

    在版本 3.0 添加了根据省份正号码获取省、市、区行政地区中文名称。

    行政地区编码源于中华人民共和国民政部,更新于 2019-06-21

  • V3.0.1 - 2019.11.05

    行政地区编码源于中华人民共和国民政部,更新于 2019-11-05

  • V3.1.0 - 2020.02.23

    行政地区编码源于中华人民共和国民政部,更新于 2020-02-19

    同时更新了内部实现的机制,调用的方法已经改变了,但是兼容低版本,建议更新旧的调用方法,将于2020.08.01不再支持旧的sdk

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].