jarir-ahmed/bd-nid-parser
Composer 安装命令:
composer require jarir-ahmed/bd-nid-parser
包简介
Parse and validate Bangladesh National ID (NID) numbers. Extract number, digit type (10/17), date of birth, and name from raw OCR text. Zero dependencies.
README 文档
README
Parse and validate Bangladesh National ID (NID) numbers. Extract NID number, digit type (10-digit old card / 17-digit smart card), date of birth, and name from raw OCR text. Zero dependencies.
composer require jarir-ahmed/bd-nid-parser
Quick Start
use JarirAhmed\BdNid\BdNid; // Parse full card OCR text $result = BdNid::parse("Name: MD. JARIR AHMED NID: 4212964672 Date of Birth: 17 May 2000"); // [ // 'number' => '4212964672', // 'type' => '10', // 'name' => 'MD. JARIR AHMED', // 'dateOfBirth' => '2000-05-17', // ] // Validate NID number BdNid::validate('4212964672'); // true BdNid::validate('12345678901234567'); // true (smart card) BdNid::validate('12345'); // false // Detect card type BdNid::getDigitType('4212964672'); // '10' BdNid::getDigitType('12345678901234567'); // '17'
API
parse(string $text): array
Extract NID number, type, name, and DOB from raw OCR text.
Returns:
number— NID number (digits only), ornulltype—'10'(old card) or'17'(smart card), ornullname— Person name in uppercase, ornulldateOfBirth— DOB inYYYY-MM-DDformat, ornull
validate(string $number): bool
Check if an NID number is valid (10 or 17 digits).
getDigitType(string $number): ?string
Detect card type: '10' or '17', returns null if invalid.
Supported DOB Formats
| Format | Example |
|---|---|
| Date of Birth: DD Mon YYYY | Date of Birth: 17 May 2000 |
| DD Mon YYYY (standalone) | 05 January 1990 |
| DD-MM-YYYY | 01-12-1990 |
| DD/MM/YYYY | 15/06/1985 |
| YYYY-MM-DD (ISO) | 1990-01-17 |
| DD-Mon-YYYY | 01-Jan-1995 |
Supports both English and Bangla (নাম) name extraction.
Optional: NID Verification via nidlive.com
The package includes an optional NidLiveVerifier that integrates with nidlive.com — an identity verification service using image-based face/NID matching. This package uses their API for verification, and we credit them for providing this service.
To use the verifier, sign up at nidlive.com, purchase a subscription, and obtain your Client ID & Secret from the dashboard.
use JarirAhmed\BdNid\Verifiers\NidLiveVerifier; $verifier = new NidLiveVerifier( clientId: 'your-client-id', clientSecret: 'your-client-secret' ); // Submit NID front/back images + selfie for verification $result = $verifier->submitVerification( nidFrontBase64: $frontImageBase64, nidBackBase64: $backImageBase64, selfieBase64: $selfieBase64, ); // Check verification status $status = $verifier->checkStatus('VRF-ABC123'); // Test API connectivity (no auth required) $info = $verifier->testConnection();
nidlive.com Plans
| Plan | API Calls | Rate Limit |
|---|---|---|
| Starter | 1,000 / month | 60 / minute |
| Professional | 10,000 / month | 300 / minute |
| Enterprise | Custom | Custom |
Requires ext-curl and ext-json. See full API docs at nidlive.com/api-docs.
Testing
composer install
composer test
License
MIT
bd-nid-parser
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-07-09