Download the PHP package ballspins/nik-parser without Composer

On this page you can find all versions of the php package ballspins/nik-parser. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package nik-parser

NIK Parser: Industrial-Grade Low-Memory Binary Search

Parser NIK KTP Indonesia dengan performa tinggi dan konsumsi memori ekstrem minimal (< 4 MB). Dirancang untuk skalabilitas maksimal, parser ini tidak memuat dataset ke RAM, melainkan menggunakan teknik Binary Search langsung pada berkas biner.

Telah tervalidasi stabil untuk pemrosesan hingga 1 juta data tanpa adanya degradasi performa memori.

Mengapa Pendekatan Ini?

Kebanyakan parser NIK di Node.js menggunakan pendekatan Memory-Resident Hash Map (meload seluruh JSON ke RAM), yang menyebabkan konsumsi memori membengkak seiring bertambahnya dataset. NikParser menggunakan Disk-Backed Binary Stream:


API Reference

1. NikParser (Parsing Data)

Metode ini digunakan untuk membaca dan mengekstrak informasi dari NIK yang sudah ada.

Metode Deskripsi
isValid() Validasi integritas NIK secara keseluruhan.
province() Mendapatkan nama provinsi berdasarkan NIK.
kabupatenKota() Mendapatkan nama kabupaten/kota.
kecamatan() Mendapatkan nama kecamatan.
birthDate() Mendapatkan objek DateTime tanggal lahir.
kelamin() Deteksi gender (pria / wanita).
getDetails() Mengembalikan seluruh data NIK dalam format associative array.

2. NikGenerator (Pembuatan Data)

Metode statis untuk membuat NIK baru sesuai dengan format standar.

Metode Deskripsi
generate($kecamatanId, $birthDate, $gender, $randomCode) Membuat NIK 16 digit. Menangani otomatis offset 40 untuk NIK wanita.

Cara Penggunaan Parser

Contoh Penggunaan Generator


Perbandingan Benchmark (1 Juta Iterasi)

Pengujian dilakukan untuk membandingkan efisiensi antara Memory-Resident (Node.js) vs Disk-Backed Binary Stream (PHP).

Metrik Node.js v22.17 (JSON-based) PHP 8.3.20 (NikParser Optimized)
Execution Time (Avg) ~0.22s ~4.3s
Peak Memory Usage ~5.8 MB ~4.0 MB
Memory Complexity O(N) - Naik seiring data O(1) - Konstan

Analisis Arsitektur: Perbedaan kecepatan eksekusi disebabkan oleh perbedaan fundamental arsitektur: Node.js memuat dataset ke RAM (Memory-Resident), sedangkan NikParser membaca langsung dari disk (Disk-Resident). Pendekatan Disk-Resident dipilih dengan sengaja untuk menjamin batas konsumsi memori yang konstan dan mencegah risiko Out of Memory pada dataset masif.

Konteks Real-World: Benchmark 1 juta iterasi di atas adalah stress test ekstrem. Dalam skenario aplikasi web nyata yang umumnya memproses 1-5 NIK per request, latensi I/O sebesar ~4 mikrodetik per pencarian tidak akan terasa oleh pengguna akhir (user experience tetap terasa instan), namun stabilitas penggunaan RAM yang rendah memberikan keuntungan besar pada skalabilitas server.

Menambahkan spesifikasi lingkungan pengujian (benchmark environment) adalah langkah yang sangat valid dan profesional. Dalam dunia engineering, hasil benchmark tanpa konteks spesifikasi perangkat sering dianggap "kosong" karena variabel hardware sangat memengaruhi hasil (terutama pada disk I/O).

Berikut adalah cara menambahkan informasi tersebut ke dalam README agar hasil benchmark kamu kredibel:

Lingkungan Benchmark (Benchmark Environment)

Benchmark dijalankan di lingkungan lokal untuk memastikan konsistensi hasil. Perlu diingat bahwa performa pada NikParser sangat bergantung pada kecepatan disk I/O (SSD vs HDD) karena arsitekturnya yang berbasis Disk-Resident.

Komponen Spesifikasi
OS Windows 11 Home Single Language (Build 26100)
CPU AMD Ryzen 3 7320U (4 Cores, 8 Threads)
RAM 8GB (6.8 Installed) LPDDR5 5500 MT/s
Storage NVMe SSD Gen 4
PHP Version 8.3.20 (CLI)
Node.js Version 22.17.0

Catatan Hardware: Benchmark ini menggunakan NVMe SSD. Jika dijalankan pada HDD konvensional, latensi I/O untuk PHP akan meningkat secara signifikan dibandingkan hasil di atas. Namun, efisiensi memori (4MB) akan tetap konstan pada perangkat apa pun.

Cara Verifikasi Performa

Kamu bisa memverifikasi hasil benchmark di lingkungan lokal menggunakan skrip berikut (benchmark.php):

Spesifikasi Teknis: Fixed-Width Binary

Setiap baris data dalam wilayah.bin memiliki panjang statis 50 byte, memungkinkan akses instan ke posisi byte spesifik menggunakan fseek().

  1. Kode Wilayah (6 byte): Indeks pencarian ($O(\log N)$).
  2. Tipe (1 byte): Penanda wilayah.
  3. Kodepos (5 byte): Padded string.
  4. Nama Wilayah (38 byte): Padded string.

Catatan Penting


Utility Scripts

Proyek ini menyediakan perintah shortcut melalui Composer untuk pemeliharaan data:

Referensi

Dataset wilayah dan referensi logika parsing dalam proyek ini diadaptasi dari implementasi mul14/nik_parser. Penggunaan dataset tersebut ditujukan untuk mempermudah pemetaan kode wilayah NIK KTP Indonesia.


All versions of nik-parser with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package ballspins/nik-parser contains the following files

Loading the files please wait ...