Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Hashids Laravel Package

erikwang2013/hashids

Laravel/PHP wrapper for Hashids that encodes integers into short, unique, non-sequential IDs and decodes them back. Useful for obfuscating database IDs in URLs and APIs while keeping values reversible and configurable.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Snapshot: erikwang2013/hashids v1.3.1 — a Laravel wrapper around the hashids/hashids core library. The release notes for v1.3.1 contain only a compare link between v1.3.0 and v1.3.1; no changelog entries, no described changes, no linked issues or PRs. Treat the release as a presumed non-breaking patch based on semver position alone, not on verified content.

Architecture fit

  • Purpose-fit for one narrow, well-understood job: encoding auto-increment integer primary keys into short, non-sequential, human-friendly tokens for URLs, share links, invoice numbers, referral codes, and public-facing identifiers.
  • It is a presentation/transport-layer obfuscator, not a security control. Hashids output is reversible by anyone who knows the salt and alphabet. Any design that treats these tokens as authorization (e.g. "if you have the link you may view the record") must still enforce object-level authorization server-side.
  • Fits cleanly into Laravel idioms: service provider, facade, publishable config, container binding. Low architectural surface area — it does not touch the ORM, request lifecycle, queue, or cache layers, so it does not constrain broader architecture decisions.
  • Poor fit wherever IDs must be unpredictable and unguessable (password reset tokens, API keys, signed URLs, capability tokens). Those need CSPRNG-backed opaque tokens with server-side lookup, not reversible encoding.

Integration feasibility

  • Very low effort to a first working call: install, publish config, set salt and alphabet, inject the facade or the underlying encoder. Realistic estimate is under a day for a proof of concept, 1–3 days to do it properly across a codebase with tests.
  • The genuine cost is not the library, it is the cross-cutting change to identifier handling: route model binding, API resources, serializers, seeders, fixtures, front-end clients, deep links, and analytics that currently assume numeric IDs.
  • No database migration is required if you encode on output — which is the recommended pattern. The integer PK stays authoritative; hashing happens at boundaries.

Technical risk

Risk Severity Notes
Reversibility misunderstood as security High Teams routinely assume "short and scrambled" means "secret". Needs an explicit, written architectural rule.
Salt is a hard, permanent commitment High Changing the salt or alphabet invalidates every previously issued identifier. Rotating the salt is a data-migration event, not a config change.
Collision / length pressure Medium Uniqueness depends on the integer space, minimum hash length, and alphabet chosen. Very large ID ranges or small alphabets can push you into longer or ambiguous strings. Must be validated against projected ID volume at 3–5 years, not today's row count.
Alphabet curation Medium Excluding look-alikes (0/O, 1/l/I) and profanity is a manual review task. The default alphabet should not ship unexamined to a consumer-facing surface.
Abandonware / fork drift Medium-High This is a small-maintainer fork of a previously popular wrapper. Contributor count, issue responsiveness, and release cadence are the real health signals — and this release gives us almost nothing to read.
Silent patch contents Medium v1.3.1 ships with no described changes. A patch could carry a dependency bump, an internal refactor, or a security-adjacent fix. The absence of a changelog is itself a governance finding.
Transitive dependency exposure Low-Medium Security posture is largely inherited from the hashids/hashids core and Laravel support versions.

Key questions for the maintainer / vendor

  1. What actually changed in v1.3.1? Request a real changelog, a diff summary, and a linked PR for every release going forward.
  2. Which Laravel and PHP versions are actively supported and CI-tested? Is there a stated support matrix and deprecation policy?
  3. What is the maintainer's intended level of commitment — is this maintained, best-effort, or effectively archived?
  4. Is there a documented, tested path for salt rotation, or is it accepted as a one-way door?
  5. Where does the project stand on the "hashids is obfuscation, not encryption" distinction in its own documentation? If the docs are ambiguous, expect downstream misuse.
  6. Are there published guidance and tests for collision behavior at high ID volumes and for alphabet customization?

Integration Approach

Stack fit

  • Laravel-native and conventional: config publish, facade, container binding. A Laravel engineer can read the whole integration surface in an afternoon.
  • Framework-agnostic core means the encoder can also be used in queue workers, Artisan commands, and non-HTTP contexts — useful for exports, emails, and batch jobs that must emit the same tokens.
  • No conflict with standard stack choices: Eloquent, API Resources, Inertia/Livewire, Sanctum, Horizon. It composes rather than competes.

Migration path

  1. Contain it. Wrap the package behind your own small interface (e.g. PublicIdEncoder with encode() / decode()). Nothing in the domain layer should reference the vendor namespace directly. This is the single highest-value decision here — it makes the package swappable and makes a future salt-rotation project tractable.
  2. Keep integers authoritative. Storage stays integer PK/FK. Encode at the serialization boundary; decode at the route-binding boundary. Never store only the hash.
  3. Introduce dual-read compatibility. Accept both numeric and hashed identifiers on inbound routes during transition, emit hashed only on outbound. Deprecate numeric acceptance on a dated schedule.
  4. Backfill nothing. Because encoding is deterministic and stateless, no data migration is needed for the happy path — a large part of why this is a low-risk change.
  5. Treat salt as a secret from day one. Load from environment/secret manager, not a committed config file, and record the value in the same custody process as other long-lived secrets.

Compatibility

  • Verify the supported Laravel/PHP matrix against the versions actually in use before committing; a wrapper package's Laravel constraint is the usual first friction point on upgrade.
  • Pin deliberately. Given the empty changelog, prefer a pinned minor (1.3.*) with a scheduled review, rather than floating to ^1.0, until release hygiene improves.
  • Confirm behavior against PHP 8.x deprecation notices and against the project's static-analysis and test baselines.
  • Check whether the facade alias collides with anything already registered.

Sequencing

  1. Spike: encode/decode round-trip, collision and length validation against projected ID volume, alphabet review. (~2 days)
  2. Internal wrapper + config/secrets wired. (~2 days)
  3. Outbound encoding on one low-risk surface — an internal admin URL or a non-critical share link — and observe. (~1 week elapsed)
  4. Expand to public-facing routes with dual-read enabled; update clients, docs, and tests.
  5. Retire numeric inbound acceptance only after analytics confirm no live traffic depends on it.

Sequence the salt and alphabet decision before any public identifier is issued. It is the one irreversible choice in the whole effort.

Operational Impact

Maintenance

  • Steady-state effort is near zero: no background jobs, no daemons, no state, no schema. This is the main operational argument in its favor.
  • The real maintenance burden is the pinned salt and alphabet — they become a long-lived compatibility contract, and any leak, audit finding, or policy change forces a coordinated migration across every stored link, exported report, and third-party integration that captured an identifier.
  • Budget a recurring dependency-review line item: this package needs a human to read its diff each release, precisely because its changelog does not describe itself.

Support

  • Low internal support load in normal operation — failures are deterministic and reproducible, not intermittent.
  • Escalation path is thin: a small-maintainer fork means upstream fixes are best-effort. Plan for the realistic scenario where the team must vendor or fork the wrapper. The internal PublicIdEncoder abstraction is what makes that a contained task rather than a rewrite.
  • Documentation debt is the likeliest source of misuse: without an explicit internal standard, a future engineer will assume these tokens are secret. Write that rule down where the architecture is documented, not just in a PR description.

Scaling

  • Encoding/decoding is CPU-trivial and stateless; it will not be a throughput bottleneck at any plausible volume. Horizontal scaling is a non-issue.
  • The scaling dimension that actually matters is identifiers issued over time: hash length is a function of ID magnitude and configuration. Validate the chosen parameters against multi-year ID growth so length does not silently drift and break fixed-width UI assumptions, column constraints, or client-side validation.
  • No cache or shared state is required, which removes an entire class of distributed-systems failure.

Failure modes

Failure mode Blast radius Detection & mitigation
Salt changed or lost Every previously issued link breaks at once; irreversible Secret-managed, backed up, access-controlled, and documented as a permanent contract. Test the decode path against a stored fixture.
Malformed / truncated token Single request 404 or 500 instead of 404 Never let the decoder throw into the HTTP layer; catch and translate to 404. Add negative tests.
Decoded ID does not exist Enumeration probing of the ID space Reversibility means an attacker can walk the space. Enforce authz on every lookup; rate-limit public endpoints; monitor 404 ratios.
Length drift after config edit Silent truncation in UI or DB columns Treat hash length as a contract; assert it in a test; alert on config diff.
Silent upstream patch introduces behavior change Diffuse, hard to attribute Pin versions; require a changelog before bumping; rely on round-trip property tests as the gate.
Package abandonment Slow accumulation of unpatched risk Wrapper abstraction keeps the exit cheap; review health signals annually.

Ramp-up

  • A Laravel engineer is productive in under a day for the mechanics; the conceptual briefing (reversible ≠ secret, salt is permanent, integers stay authoritative) matters more than the API and should be part of onboarding.
  • Do not expect the library to teach the right usage pattern. The team's own wrapper, tests, and a short written standard are the actual onboarding artifacts.
  • The knowledge most at risk of walking out the door is not the API but the rationale behind the chosen salt/alphabet/length parameters and the rotation plan. Record it.

TPM recommendation (provisional, pending the answers in Key Questions)

Adopt for public identifier obfuscation behind an internal abstraction, on a pinned version, with a secret-managed salt and a pre-agreed alphabet. Do not adopt as a security or authorization mechanism. Do not treat v1.3.1 as validated — it is a patch with no described contents, which is acceptable for a pin-and-review policy but is a standing release-hygiene concern worth raising with the maintainer before this becomes load-bearing. Overall risk for the intended use case is low-to-moderate, driven almost entirely by the salt contract and the project's thin maintenance signal rather than by anything in this release.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core