ofcold/identity-card
Composer 安装命令:
composer require ofcold/identity-card
包简介
A simple proof of identity card of the people's Republic of China.
README 文档
README
China (region) citizen ID card tool
Simplified Chinese Documentation
China (Mainland) ID card package, the data from the national standard
GB/T 2260-2007(People's Republic of China administrative divisions code standard).
Other Language
Installing
composer require ofcold/identity-card
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 in Laravel Validation
Multi-language add
Please enter a valid Id Cardto 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
// 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.
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:
{
"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
- 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
V3.0.0
- Added Laravel Rule.
V2.0.0
ofcold/identity-card 适用场景与选型建议
ofcold/identity-card 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 40.86k 次下载、GitHub Stars 达 188, 最近一次更新时间为 2018 年 05 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「region」 「area」 「ID Card」 「php7.x」 「php8.x」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 ofcold/identity-card 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ofcold/identity-card 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 ofcold/identity-card 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Miaoxing Region Plugin
Philippines region, province, cities/municipalities and barangays Laravel migration and table seeder.
Settings Card for Laravel Nova.
A tool for scraping URL resources (oEmbed, OpenGraph, Twitter cards, JSON-LD)
List of Italian Regioni (Regions), Province (Provinces), and Comuni (Municipalities) with data from Istat
Impersonate kirby users in the panel
统计信息
- 总下载量: 40.86k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 189
- 点击次数: 30
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-05-18