1. Go to this page and download the library: Download lalusahibul/fakenik library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
lalusahibul / fakenik example snippets
//config/fakenik.php
'default_code' => [
'province' => '52', // Example: Nusa Tenggara Barat
'regency' => '05', // Example: Kabupaten Dompu
'district' => '06', // Example: Kecamatan Pekat
],
'birth_year_range' => [
'min' => 1970,
'max' => 2010,
],
use Fakenik\Generator;
use Fakenik\DateOfBirth;
use Illuminate\Support\Facades\Route;
use Fakenik\Generator;
use Fakenik\DateOfBirth;
Route::get('/example', function () {
// Generate a complete NIK using default settings.
// The birth year range and default region codes are pulled from the `fakenik.php` config file.
// To customize these values, you can publish the configuration file.
$tahunLahir = DateOfBirth::generateBirthYear();
$bulanLahir = DateOfBirth::generateBirthMonth();
$tanggalLahir = DateOfBirth::generateBirthDay($bulanLahir, $tahunLahir);
$nik = Generator::generate($tanggalLahir, $bulanLahir, $tahunLahir);
return response()->json([
'nik_tergenerate' => $nik,
'detail_tanggal_lahir' => [
'tanggal' => $tanggalLahir,
'bulan' => $bulanLahir,
'tahun' => $tahunLahir,
]
]);