Skip to content

Releases: pikaid/pikaid-php

v1.1.1

18 Apr 08:59
b8075b1

Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v1.1.0...v1.1.1

Release v1.1.0

23 Aug 14:31

Choose a tag to compare

Official PHP implementation aligned with Pikaid spec v1.0.1

Highlights

  • Binary form (BINARY(17)): native support and round-trip with the 26-char string. Binary lexicographic order equals chronological order (1-second precision).
  • Normative compliance: generation, parsing, validation, ordering, and interop now strictly follow the v1.0.1 specification (RFC 2119 wording).
  • Stronger API surface: convenient converters (toBinary, fromBinary) and direct generateBinary().

Added

  • Pikaid::generateBinary(): string β€” generate IDs directly in the compact 17-byte binary layout ([5B uint40 big-endian timestamp][12B entropy]).
  • Pikaid::toBinary(string $id): string β€” convert a 26-char ID to its exact 17-byte binary form; strict validation with descriptive exceptions.
  • Pikaid::fromBinary(string $bin): string β€” convert 17-byte binary back to the 26-char string; rejects any non-17-byte input.
  • Pikaid::parse(string $id): array β€” returns timestamp (DateTimeImmutable, UTC) and randomness (24-char lowercase hex / 12 bytes).
  • Storage recommendations in README: schemas and examples for BINARY(17) (recommended) and CHAR(26) with sorting guarantees and generated columns.
  • Badges & docs polish: β€œOfficial implementation” badge and explicit link to the spec repo.

Changed

  • Validation & parsing: clarified and enforced seconds precision; timestamp range checks aligned to 0..36^7βˆ’1.
  • Error handling: invalid formats, out-of-range timestamps, and wrong binary lengths now raise InvalidArgumentException with precise messages.
  • Performance guidance: README recommends ext-gmp (best) with ext-bcmath fallback; pure-PHP path remains available.

Fixed

  • Consistent wording and examples in README (typos, seconds vs ms).
  • Test coverage expanded for:
    • string ⇄ binary round-trip,
    • lexicographic = chronological ordering (string and binary),
    • edge-case validation (length, charset, out-of-range timestamp),
    • conversion determinism across PHP extensions.

Migration notes (no breaking changes)

  • Existing 26-char IDs remain valid and sortable.
  • For compact storage and faster indexes, migrate to BINARY(17):
    • Use Pikaid::toBinary() when writing, and Pikaid::fromBinary() when reading.

Quick SQL reminder

  • Binary (recommended): BINARY(17) primary key for compact clustered indexes and natural chronological ordering.
  • String: CHAR(26) CHARACTER SET ascii COLLATE ascii_bin for human-readable IDs; optional generated column for range queries.

API recap

  • Pikaid::generate(): string
  • Pikaid::generateBinary(): string
  • Pikaid::toBinary(string $id): string
  • Pikaid::fromBinary(string $bin): string
  • Pikaid::isValid(string $id): bool
  • Pikaid::parse(string $id): array
  • Pikaid::fromDateTime(DateTimeInterface $t): string

Release v1.0.3

23 Aug 07:54
bf89890

Choose a tag to compare

What's Changed

  • Composer metadata: Added suggest entries for optional extensions:
    • ext-gmp β†’ Fastest Base36 conversions (recommended)
    • ext-bcmath β†’ Faster than pure-PHP fallback if GMP is unavailable
  • No changes to the library code or API β€” this is purely a metadata update to guide users on performance tuning.

Release v1.0.2

23 Aug 07:45
921e0a1

Choose a tag to compare

What's Changed

  • Performance: Optimized Base36 conversions with a clear fallback chain:
    • GMP (fastest, recommended)
    • BCMath (official PHP extension)
    • Native pure-PHP implementation (no extensions required)
  • Validation: Enforce strict 96-bit bound during parsing for consistency.
  • Optimizations: Micro-optimizations in bigint handling and timestamp encoding.
  • Docs: Clarified extension recommendations in README.

Release v1.0.1

07 Aug 07:42

Choose a tag to compare

Code and perfs improvements.

Release v1.0.0

16 May 16:44

Choose a tag to compare

Initial release for pikaid-php, the offcial pikaid PHP implementation.