PHPackages                             sangkan/wiji - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. sangkan/wiji

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

sangkan/wiji
============

Wiji (ꦮꦶꦗꦶ) — Optimized Unique Identifier. 128-bit, µs-precision, monotonic, multi-format. By Sangkan.

v1.0.0(3mo ago)10MITSveltePHP &gt;=7.3CI failing

Since Mar 26Pushed 3mo agoCompare

[ Source](https://github.com/sangkan-dev/wiji)[ Packagist](https://packagist.org/packages/sangkan/wiji)[ Docs](https://sangkan.dev)[ RSS](/packages/sangkan-wiji/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependenciesVersions (2)Used By (0)

ꦮꦶꦗꦶ Wiji — monorepo
====================

[](#ꦮꦶꦗꦶ-wiji--monorepo)

**Wiji** adalah 128-bit **time-ordered identifier** (timestamp-first) untuk sistem yang butuh urutan yang rapi di database, monotonic generator, dan ekstraksi waktu presisi microsecond (µs).

Website docs: **`wiji.sangkan.dev`**.

Packages
--------

[](#packages)

- **JavaScript / TypeScript (npm)**: `js/` → `@sangkan-dev/wiji`
- **PHP (Composer)**: `sangkan/wiji` — manifest [`composer.json`](composer.json) di root repo (autoload ke `php/src/`).

Quick start
-----------

[](#quick-start)

- **JS/TS**: lihat `js/README.md`
- **PHP**: lihat `php/src/Wiji.php` dan `php/tests/WijiTest.php`. Untuk kontributor: dari root repo jalankan `composer install` lalu `composer test`.

Forged at [Sangkan](https://sangkan.dev) — Building the Source.

Deploy (Cloudflare Pages)
-------------------------

[](#deploy-cloudflare-pages)

Website lives in `site/`. Deployment notes: `site/DEPLOY_CLOUDFLARE_PAGES.md`.

---

Mengapa Wiji?
-------------

[](#mengapa-wiji)

PropertiUUID v4UUID v7ULIDKSUID**Wiji v1**Presisi timestamp—1 ms1 ms1 detik**1 µs**B+ tree friendly❌✅✅✅✅Monotonic❌SebagianSebagian❌✅Version field✅✅❌❌✅Binary output✅✅❌❌✅Zero dependencies❌❌❌❌✅String length36362627**26**Valid hingga—10889108892106**4253**---

Bit Layout
----------

[](#bit-layout)

```
 127                                                              0
  ┌──────────────────────────┬────────────────┬────┬─────────────────────────────────┐
  │       timestamp_us       │    sequence    │ver │            random               │
  │         56 bits          │    16 bits     │ 4b │            52 bits              │
  └──────────────────────────┴────────────────┴────┴─────────────────────────────────┘

```

- **56-bit timestamp µs** — microseconds sejak Unix epoch. Valid hingga tahun 4253.
- **16-bit sequence** — counter monotonic per µs, 0–65535. Overflow → tunggu µs berikutnya.
- **4-bit version** — selalu `0x1` untuk Wiji v1. Future-proof untuk evolusi spec.
- **52-bit random** — CSPRNG, di-generate sekali per generator instance. Isolasi antar proses.

---

Quick Start
-----------

[](#quick-start-1)

### JavaScript / Node.js / Bun / Deno

[](#javascript--nodejs--bun--deno)

```
npm install @sangkan-dev/wiji
```

```
import wiji from '@sangkan-dev/wiji';
// atau: const wiji = require('@sangkan-dev/wiji');

// Generate
wiji()              // → '01JKM5WXR9P003K1F4Q8XTBZN2'
wiji.binary()       // → Uint8Array(16)
wiji.uuid()         // → '019d2257-972f-1a4e-36ea-81d64ed08dfc'
wiji.hex()          // → '019d2257972f1a4e36ea81d64ed08dfc'

// Parse
wiji.parse('01JKM5WXR9P003K1F4Q8XTBZN2')
// → { timestamp_us: 1774397000000000, timestamp_ms: 1774397000000,
//     date: Date, sequence: 42, version: 1, random: Uint8Array(7) }

// Utilities
wiji.isValid('01JKM5WXR9P003K1F4Q8XTBZN2') // → true
wiji.timestampUs('01JKM5WXR9P003K1F4Q8XTBZN2') // → microseconds
wiji.compare(a, b)  // → -1 | 0 | 1
wiji.factory()      // → isolated generator instance
```

### PHP / Laravel

[](#php--laravel)

```
composer require sangkan/wiji
```

```
use Sangkan\Wiji\Wiji;

$wiji = new Wiji();

// Generate
$wiji->generate();        // → '01JKM5WXR9P003K1F4Q8XTBZN2'
$wiji->generateBinary();  // → 16 raw bytes (string)
$wiji->generateUuid();    // → '019d2257-972f-1a4e-36ea-81d64ed08dfc'
$wiji->generateHex();     // → '019d2257972f1a4e36ea81d64ed08dfc'

// Parse
Wiji::parse('01JKM5WXR9P003K1F4Q8XTBZN2');
// → ['timestamp_us' => ..., 'timestamp_ms' => ..., 'datetime' => DateTimeImmutable, ...]

// Utilities
Wiji::isValid('01JKM5WXR9P003K1F4Q8XTBZN2'); // → true
Wiji::timestampUs($id);   // → int (microseconds)
Wiji::compare($a, $b);    // → -1 | 0 | 1
```

#### Laravel — Eloquent integration

[](#laravel--eloquent-integration)

```
// database/migrations/xxxx_create_posts_table.php
Schema::create('posts', function (Blueprint $table) {
    $table->string('id', 26)->primary();
    // atau binary:
    // $table->binary('id', 16)->primary();
    $table->string('title');
    $table->timestamps();
});

// app/Models/Post.php
use Sangkan\Wiji\Wiji;

class Post extends Model
{
    protected $keyType = 'string';
    public $incrementing = false;

    protected static function boot(): void
    {
        parent::boot();
        static::creating(function (self $model) {
            if (empty($model->{$model->getKeyName()})) {
                $wiji = new Wiji();
                $model->{$model->getKeyName()} = $wiji->generate();
            }
        });
    }
}
```

---

Database Storage
----------------

[](#database-storage)

DatabaseColumn typeNotesMySQL / MariaDB`VARCHAR(26)`Primary, natural sortMySQL / MariaDB`BINARY(16)`Compact, fastest indexPostgreSQL`CHAR(26)` atau `UUID`UUID format via `generateUuid()`SQLite`TEXT`DefaultMongoDBStore as stringNatural sort preserved---

Performance
-----------

[](#performance)

Measured on Node.js 22, PHP 8.3 (single core):

IDs/secWiji JS (string)~800kWiji JS (binary)~3.5MWiji PHP (string)~290kUUID v4 (JS)~1.7MULID (JS npm)~4k> Wiji binary output adalah yang tercepat untuk pipeline yang pakai binary storage.

---

Implementasi
------------

[](#implementasi)

BahasaPackageStatusJavaScript / TypeScript`@sangkan-dev/wiji`✅ StablePHP`sangkan/wiji`✅ StablePython`sangkan-wiji`🔜 Coming soonGo`github.com/sangkan-dev/wiji-go`🔜 Coming soonRust`wiji` (crates.io)🔜 Coming soon---

Composer (Packagist) — rilis
----------------------------

[](#composer-packagist--rilis)

`composer.json` untuk paket `sangkan/wiji` berada di **root** monorepo ini agar [Packagist](https://packagist.org) bisa membacanya.

1. Commit &amp; push perubahan ke GitHub (`sangkan-dev/wiji`).
2. Buat tag semver dan push, contoh: `git tag v1.0.0` lalu `git push origin v1.0.0` — versi di Composer mengikuti tag (`v` di depan opsional; Packagist umumnya mengenali `v1.0.0` / `1.0.0`).
3. Di Packagist: **Submit** → masukkan URL repo `https://github.com/sangkan-dev/wiji`.
4. Ikuti langkah **GitHub webhook** di Packagist agar tag/commit baru terindeks otomatis.

Setelah terdaftar, pengguna memasang dengan: `composer require sangkan/wiji`.

---

Specification
-------------

[](#specification)

Lihat [`WIJI_SPEC.md`](WIJI_SPEC.md) untuk spesifikasi lengkap, termasuk bit layout, byte layout, test vectors, dan panduan implementasi di bahasa lain.

Spec dirilis di bawah [CC0 1.0](https://creativecommons.org/publicdomain/zero/1.0/) — public domain. Siapapun boleh mengimplementasikan Wiji tanpa batasan.

---

License
-------

[](#license)

MIT — lihat [LICENSE](LICENSE)

---

*Forged at [Sangkan](https://sangkan.dev) — Building the Source.**Inspired by "Sangkan Paraning Dumadi" — memahami asal dan tujuan dari segala ciptaan.*

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance82

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity29

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

91d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/112043708?v=4)[HasanH47](/maintainers/HasanH47)[@HasanH47](https://github.com/HasanH47)

---

Top Contributors

[![HasanH47](https://avatars.githubusercontent.com/u/112043708?v=4)](https://github.com/HasanH47 "HasanH47 (6 commits)")

---

Tags

uuididentifierulidunique-idtimestampwijimonotonicsangkan

### Embed Badge

![Health badge](/badges/sangkan-wiji/health.svg)

```
[![Health](https://phpackages.com/badges/sangkan-wiji/health.svg)](https://phpackages.com/packages/sangkan-wiji)
```

###  Alternatives

[ramsey/uuid

A PHP library for generating and working with universally unique identifiers (UUIDs).

12.6k729.6M3.8k](/packages/ramsey-uuid)[symfony/uid

Provides an object-oriented API to generate and represent UIDs

610303.9M1.1k](/packages/symfony-uid)[pascaldevink/shortuuid

PHP 7.4+ library that generates concise, unambiguous, URL-safe UUIDs

5941.8M16](/packages/pascaldevink-shortuuid)[keiko/uuid-shortener

A simple shortener library for RFC 4122 compatible UUIDs. Change your 36 chars long UUID into it's shorter equivalent.

150223.6k3](/packages/keiko-uuid-shortener)[identifier/identifier

Common Interfaces and Factories for Identifiers

3231.4k1](/packages/identifier-identifier)[ramsey/identifier

A PHP library for generating and working with identifiers, including UUIDs, ULIDs, and Snowflakes

605.2k2](/packages/ramsey-identifier)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
