lastguest/murmurhash
A fast, dependency-free PHP implementation of MurmurHash (MurmurHash3) for non-cryptographic hashing. Generate consistent 32/128-bit hashes for sharding, caching keys, bloom filters, and partitioning. Simple API, Composer-ready, and easy to drop into Laravel or any PHP project.
Architecture fit. MurmurHash3 is a non-cryptographic, high-diffusion 32/128-bit hash. In a Laravel codebase it is not an architectural component — it is a leaf utility that shows up in four places: consistent-hash ring / shard assignment (cache, queue, DB partition keys), deterministic experiment bucketing (feature flags, A/B cohorts), deduplication and fingerprinting of payloads, and probabilistic structures (bloom filters, HyperLogLog). The package delivers exactly one static class with no framework coupling, no service provider, no config, no I/O. That is a strength for fit (zero intrusion) and a weakness for leverage (it does nothing a TPM can build a roadmap on — it is a primitive, not a capability). Adopt it only where the requirement is genuinely "stable, uniformly distributed, reproducible hash across processes and deploys," not merely "a hash."
Integration feasibility. composer require lastguest/murmurhash and call the static method. Effort is measured in hours, not sprints. The real feasibility question is not installation but whether we need MurmurHash3 specifically rather than a hash with good distribution. Decision matrix:
| Option | Availability | Throughput | Cross-language parity |
|---|---|---|---|
lastguest/murmurhash |
Composer, pure PHP | Low (userland loops, int masking) | Yes — Murmur3 is a de facto standard |
hash('xxh3') |
PHP 8.1+ native | Very high (C) | Partial |
crc32() |
Core | Very high | Yes, but poor avalanche behavior |
hash('sha256') |
Core | Medium (C, with acceleration) | Yes, cryptographic |
If the answer is "we just need spread and speed," use xxh3. If the answer is "an existing Java/ClickHouse/Spark/Redis pipeline already buckets on Murmur3 and we must agree with it," this package earns its place.
Technical risk.
xxh3/crc32. Fine for per-request bucketing; not fine for hashing every row of a large export or every event in a hot ingestion path.Key questions. Does any downstream system already compute Murmur3 such that parity is a hard requirement? What is the per-second call volume and does a userland hash fit the latency budget? Must assignments be stable for months or years across PHP upgrades? Can we satisfy the need with xxh3 plus a versioned salt? Who owns the golden-vector test suite?
Stack fit. Laravel-agnostic and version-agnostic; no illuminate/* constraints, so no Composer conflict with the framework. Bind it behind an in-house contract rather than calling the static method at call sites:
App\Support\Hashing\Hasher interface with hash(string $input, int $seed = 0): intMurmur3Hasher adapter delegating to the packageXxh3Hasher / Crc32Hasher alternates, selectable by configThis costs a day and converts an abandoned dependency into an implementation detail we can swap without touching domain code.
Migration path. Nothing to migrate in; the work is preventing migration later. Sequence:
xxh3 and crc32 at realistic payload sizes. Decide with numbers, not intuition.Compatibility. Pin the exact version in composer.json and commit the lock file. Verify on the highest PHP minor in production; watch for deprecation notices (implicit nullable params, dynamic properties) that indicate the package was written for an older runtime. If the package is used, prefer vendoring the algorithm into our own namespace over depending on the Packagist artifact — the implementation is on the order of a hundred lines, and owning it eliminates the supply-chain and abandonment questions at negligible cost while preserving byte-for-byte output (validated by the same golden vectors).
Sequencing. Golden vectors → benchmark → interface + adapter → low-blast-radius use case → optional vendoring → expand. Do not let hashing choice block feature delivery; the interface lets the algorithm decision land late.
Maintenance. Nominal runtime maintenance (no config, no migrations, no scheduled work, no external dependency) offset by a nonzero governance cost: an unmaintained, single-maintainer package on the dependency inventory. Treat it as frozen: freeze the version, forbid transitive upgrades, and require the golden-vector suite to pass on every PHP upgrade. Budget a few hours per year, not per sprint.
Support. No vendor, no SLA, no security advisories to monitor. Internal ownership must be explicit — an unwritten "whoever wrote it" is how a hashing regression goes undiagnosed for a quarter. Name an owner in the service catalog, even for a hundred lines.
Scaling. CPU-bound and single-threaded per call; scaling is linear with request/event volume and inversely with payload size. It is not a horizontal-scaling problem — it is a per-core throughput ceiling. If hashing appears in a hot loop or a queue worker processing large batches, it becomes a measurable tax on the workers that matter most. Benchmark before, not after.
Failure modes.
& 0x7fffffff or sprintf('%u', ...)), never at call sites.Ramp-up. Effectively zero — an engineer is productive in under an hour. The onboarding risk is inverted: because it is trivial, teams adopt it casually at call sites and the discipline (interface, golden vectors, unsigned normalization) is what erodes. Encode those three rules in the adapter and the CI suite so the package's simplicity does not become an argument against the guardrails.
How can I help you explore Laravel packages today?