Releases: pikaid/pikaid-php
Releases Β· pikaid/pikaid-php
v1.1.1
What's Changed
- ImproveReadMe by @zmo2s in #2
- Feature/improve read me by @zmo2s in #3
- Bump phpunit/phpunit from 12.1.5 to 12.5.22 by @dependabot[bot] in #4
New Contributors
- @zmo2s made their first contribution in #2
- @dependabot[bot] made their first contribution in #4
Full Changelog: v1.1.0...v1.1.1
Release v1.1.0
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 directgenerateBinary().
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β returnstimestamp(DateTimeImmutable, UTC) andrandomness(24-char lowercase hex / 12 bytes).- Storage recommendations in README: schemas and examples for
BINARY(17)(recommended) andCHAR(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
InvalidArgumentExceptionwith precise messages. - Performance guidance: README recommends
ext-gmp(best) withext-bcmathfallback; 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, andPikaid::fromBinary()when reading.
- Use
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_binfor human-readable IDs; optional generated column for range queries.
API recap
Pikaid::generate(): stringPikaid::generateBinary(): stringPikaid::toBinary(string $id): stringPikaid::fromBinary(string $bin): stringPikaid::isValid(string $id): boolPikaid::parse(string $id): arrayPikaid::fromDateTime(DateTimeInterface $t): string
Release v1.0.3
What's Changed
- Composer metadata: Added
suggestentries 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
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
Code and perfs improvements.
Release v1.0.0
Initial release for pikaid-php, the offcial pikaid PHP implementation.