All Projects → medz → Id Card Of China

medz / Id Card Of China

Licence: mit
🆔一个基于「公民身份号码」规则获取身份证号码中包含的基础信息组件(PHP)

Projects that are alternatives of or similar to Id Card Of China

Identity Address DB
(China) 1. MySQL 身份证 地区 数据库(包含已被合并的区县,详见README) 2. PHP 验证身份证号是否正确 3. 从身份证号中获取 性别 生日 年龄 出生地 等信息 4.路过留个star
Stars: ✭ 38 (-77.25%)
Mutual labels:  identity, china
tripreader-data
“读卡识途”项目公开数据
Stars: ✭ 58 (-65.27%)
Mutual labels:  card, china
Magic Js
Magic browser/React Native JavaScript SDK is your entry-point to integrating passwordless authentication inside your application.
Stars: ✭ 143 (-14.37%)
Mutual labels:  identity
Security.identity
.NET DevPack Identity is a set of common implementations to help you implementing Identity, Jwt, claims validation and another facilities
Stars: ✭ 165 (-1.2%)
Mutual labels:  identity
Covid 19 Timeline
以 社会学年鉴模式体例规范地统编自2019年末起新冠肺炎疫情进展的时间线。
Stars: ✭ 1,887 (+1029.94%)
Mutual labels:  china
Stripe
Stripe library for Vapor
Stars: ✭ 151 (-9.58%)
Mutual labels:  card
Vue Info Card
Simple and beautiful card component with an elegant spark line, for VueJS.
Stars: ✭ 159 (-4.79%)
Mutual labels:  card
Area Puppeteer
基于 puppeteer 的中国行政区域抓取爬虫
Stars: ✭ 144 (-13.77%)
Mutual labels:  china
China Domain Allowlist
常用中国网站白名单,纯列表,用于 SwitchyOmega,控制不走代理的网站。
Stars: ✭ 166 (-0.6%)
Mutual labels:  china
Potatso
Potatso is an iOS client that implements Shadowsocks proxy with the leverage of NetworkExtension framework. ***This project is unmaintained, try taking a look at this fork https://github.com/shadowcoel/shadowcoel instead.
Stars: ✭ 1,925 (+1052.69%)
Mutual labels:  china
Android Swipecards View
Android library to implement cards stack view with swipe to remove feature
Stars: ✭ 162 (-2.99%)
Mutual labels:  card
Py Ipv8
Python implementation of the IPv8 layer
Stars: ✭ 157 (-5.99%)
Mutual labels:  identity
Scheduler Card
HA Lovelace card for control of scheduler entities
Stars: ✭ 154 (-7.78%)
Mutual labels:  card
Active Directory B2c Dotnetcore Webapp
An ASP.NET Core web application that can sign in a user using Azure AD B2C, get an access token using MSAL.NET and call an API.
Stars: ✭ 160 (-4.19%)
Mutual labels:  identity
Minigrid
📏 Minimal 2kb zero dependency cascading grid layout
Stars: ✭ 1,801 (+978.44%)
Mutual labels:  card
Identitymanager2
Development tool for administering users and roles
Stars: ✭ 164 (-1.8%)
Mutual labels:  identity
Pci China
Policy Change Index for China (PCI-China)
Stars: ✭ 146 (-12.57%)
Mutual labels:  china
Material
A UI/UX framework for creating beautiful applications.
Stars: ✭ 11,870 (+7007.78%)
Mutual labels:  card
Chameleonmini Rebootedgui
Windows based GUI for Chameleon Mini, the contactless smartcard emulator (NFC/RFID)
Stars: ✭ 159 (-4.79%)
Mutual labels:  card
Active Directory B2c Dotnet Webapp And Webapi
A combined sample for a .NET web application that calls a .NET Web API, both secured using Azure AD B2C
Stars: ✭ 166 (-0.6%)
Mutual labels:  identity

Identity Card Of China (PHP)

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

Build Status

JavaScript 版本:https://github.com/medz/id-card-of-china-js

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

安装

  • 你的 PHP 版本应该 >= 7.0

我们使用 Composer 安装:

composer require medz/id-card-of-china

使用

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

use Medz\IdentityCard\China\Identity;

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

APIs

基于 Medz\IdentityCard\China\IdentityInterface 实例

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

region 对象 APIs

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

演示

use Medz\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(' ') // 福建省 莆田市 城厢区
);

疑问解答

  1. 问:为什么不添加年龄、星座还有属相等信息?

    答:因为年龄需要专门的时间组件去计算,星座如果是「粗略」计算可以获得,但是没有意义,属相更加复杂,负责任的转换这些属性都比简单转换复杂,简单转换出来的不够准确。同样也失去了包本身该有的功能,例如年龄可以交给「时间组件」等。

  2. 问:这个包到底干啥的?

    答:这个包就是提取公民身份号码所包含的基础信息

  3. 问:可以用来验证人或者其他的吗?

    答:不基于公安部的 API 验证的身份证组件都不能叫验证组件,现在所有的 ID Card 组件都只能提取公民身份号码所包含的信息,如果说验证,那唯一能验证的就是公民身份号码是否是一个合法的公民身份号码。

  4. 问:如何获取年龄? 答:例如在 PHP 中,获取年龄是一个很简单的时区,我用最快的例子,你依赖 nesbot/carbon 这个「时间工具」包,依赖代码:

    composer require nesbot/carbon
    

    然后看我下面的 PHP 代码:

    use Carbon\Carbon;
    $birthday = new Carbon($identity->birthday());
    $age = $birthday->diffInYears();
    

    好了,你打印下 $age 试试看!

LICENSE

This component follows the MIT open source agreement.

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].