承接 ngarak-dev/nida-parse 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ngarak-dev/nida-parse

Composer 安装命令:

composer require ngarak-dev/nida-parse

包简介

A Laravel package that attempts to reverse engineer how NIDA (National Identification Authority) numbers are generated and extract basic information from National Identification Numbers (NIN) without using the official NIDA API.

README 文档

README

A Laravel package that attempts to reverse engineer how NIDA (National Identification Authority) numbers are generated and extract basic information from National Identification Numbers (NIN) without using the official NIDA API.

This is a fork of the Python implementation: reverse_nida

⚠️ Disclaimer

This project is for educational and research purposes only. It attempts to understand the structure and patterns in NIDA numbers through reverse engineering. The accuracy of extracted information is not guaranteed, and this should not be used for official verification purposes.

🚀 Installation

Requirements

  • PHP >= 8.2
  • Composer
  • Laravel 11.x or 12.x

Install via Composer

composer require ngarak-dev/nida-parse

Publish Configuration and Assets

Publish the configuration file:

php artisan vendor:publish --tag=nida-parse-config

Publish the CSV location files to storage:

php artisan vendor:publish --tag=nida-parse-csv

Or publish both at once:

php artisan vendor:publish --provider="NidaParse\NidaParseServiceProvider"

📖 Usage

Using the Helper Function

// The helper function is autoloaded globally
// Analyze a NIDA number (supports both dashed and compact formats)
$ninDashed = "19990504-35710-00001-28";
$ninCompact = "19990504357100000128";

// Get basic information
$info = get_basic_info($ninDashed, null, false);
print_r($info);
// Output: [
//   'BIRTHDATE' => '1999-05-04',
//   'GENDER' => 'FEMALE',
//   'REGIONCODE' => '35',
//   'REGION' => 'MOROGORO',
//   'DISTRICT' => 'MOROGORO URBAN',
//   'WARDCODE' => '35710',
//   'WARD' => 'Mazimbu',
//   'STREET' => '',
//   'PLACES' => '',
// ]

// Get full information with debug
$info = get_basic_info("19990504-35710-00001-28", null, true);

Using the Service Classes Directly

use NidaParse\Services\NidaService;
use NidaParse\Services\LocationLookup;
use NidaParse\Services\NidaParser;

// Parse NIN
$parsed = NidaParser::parse("19990504-35710-00001-28");

// Lookup location
$lookup = new LocationLookup();
$location = $lookup->getAdministrativeHierarchy("35710");

// Get complete info using dependency injection
$service = app(NidaService::class);
$info = $service->getBasicInfo("19990504-35710-00001-28");

Using Dependency Injection

use NidaParse\Services\NidaService;

class YourController extends Controller
{
    public function __construct(
        protected NidaService $nidaService
    ) {}

    public function parseNin(string $nin)
    {
        $info = $this->nidaService->getBasicInfo($nin);
        return response()->json($info);
    }
}

🔧 Configuration

After publishing the configuration file, you can customize the package behavior in config/nida-parse.php:

return [
    'csv_directory' => storage_path('app/location_files_code'),
    'combined_csv_path' => null, // Set to path of combined CSV if available
];

How Location Lookup Works

The package uses a smart lookup strategy:

  1. Combined File (Preferred): If tanzania_locations_combined.csv exists in storage/app/ (after publishing), it will be used first for faster lookups.
  2. Individual Files (Fallback): If the combined file is not found or doesn't contain the ward code, the package falls back to individual region CSV files (11.csv, 21.csv, etc.).

The combined file is automatically published when you run:

php artisan vendor:publish --tag=nida-parse-csv

You can also override the CSV directory or combined file path when instantiating LocationLookup:

// Custom CSV directory
$lookup = new LocationLookup('/custom/path/to/csv/files');

// Custom combined file path
$lookup = new LocationLookup(null, '/path/to/combined.csv');

📝 NIN Format

The package supports two NIN formats:

  1. Dashed format: YYYYMMDD-LLLLL-SSSSS-XX

    • Example: 19990504-35710-00001-28
  2. Compact format: YYYYMMDDWWWWWSSSSSXX

    • Example: 19990504357100000128

Where:

  • YYYYMMDD: Birth date (Year, Month, Day)
  • LLLLL: Ward code (5 digits)
  • SSSSS: Sequence number (5 digits)
  • XX: Unknown/check digits (2 digits, first digit indicates gender)

📁 Package Structure

nida-parse/
├── src/
│   ├── Services/
│   │   ├── LocationLookup.php
│   │   ├── NidaParser.php
│   │   └── NidaService.php
│   ├── Helpers/
│   │   └── nida_helper.php
│   └── NidaParseServiceProvider.php
├── config/
│   └── nida-parse.php
├── resources/
│   ├── location_files_code/
│   │   ├── 11.csv
│   │   ├── 21.csv
│   │   └── ... (other region CSV files)
│   └── tanzania_locations_combined.csv
└── composer.json

🧪 Testing

composer test

📄 License

MIT

🙏 Credits

  • Original Python implementation by Henrylee
  • Laravel package conversion by Ngara Wambura

🔗 Links

ngarak-dev/nida-parse 适用场景与选型建议

ngarak-dev/nida-parse 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 01 月 23 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「parser」 「laravel」 「identification」 「nin」 「tanzania」 「nida」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 ngarak-dev/nida-parse 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 ngarak-dev/nida-parse 我们能提供哪些服务?
定制开发 / 二次开发

基于 ngarak-dev/nida-parse 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 2
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 31
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-23