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

Eloquent Hashids Laravel Package

mtvs/eloquent-hashids

Laravel package that integrates Hashids with Eloquent models, letting you hide sequential IDs behind short, unique hashids. Add the HasHashid trait to expose a hashid attribute, query models by hashid, and use hashids in route model binding while keeping your database keys unchanged.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

  • Architecture fit: Narrow Laravel/Eloquent add-on that computes Hashids from integer primary keys on the fly. It fits monoliths and API layers that need opaque public identifiers without schema changes, but it is not a security boundary, UUID/ULID replacement, or authorization mechanism.
  • Integration feasibility: High for a small set of models. Add the trait, configure salt/alphabet/min length, expose a hashid accessor, and decode hashes at route/controller boundaries. Main effort is route model binding, invalid-hash handling, and API serialization tests.
  • Technical risk: Hashids is reversible obfuscation; anyone with the salt can recover IDs. Salt rotation breaks existing links. Package maturity and Laravel/PHP version compatibility must be verified. Malformed hashes can surface as 500s if decoding is not guarded. Accidental numeric-ID exposure remains possible in logs, resources, and relations.
  • Key questions: Which models and public surfaces require opaque IDs? Is Hashids acceptable versus UUID/ULID? What Laravel/PHP versions are supported by the package and its Hashids dependency? Is route model binding required or only API serialization? Who owns salt rotation and fork/maintenance if the package lags? What is the performance budget for serializing large collections?

Integration Approach

  • Stack fit: Fits Laravel’s trait/config pattern and coexists with API Resources, route model binding, and existing integer foreign keys. Keep integer PKs internal; expose hashids only at external boundaries.
  • Migration path: No database migration or backfill because hashids are computed. Existing numeric URLs can be supported temporarily with a dual resolver or redirects, then retired.
  • Compatibility: Validate Composer constraints against the current Laravel/PHP matrix and the underlying Hashids version. Test config caching, route binding, serialization, and polymorphic relations. If the package lags, wrap it in an application-level trait/adapter and pin or fork.
  • Sequencing: Spike on one non-critical model; define salt/alphabet/min-length per environment; add trait and resolver; update routes/resources; add invalid-hash and compatibility tests; roll out behind a feature flag; monitor 404/500 rates and broken-link reports.

Operational Impact

  • Maintenance: Low code footprint, but an external dependency. Pin versions, watch releases, and maintain an adapter/fork path. Treat the salt as an operational secret with documented rotation impact.
  • Support: Simple for Laravel developers; support burden is mostly broken links after salt changes and confusion about hashids not being encryption. Document which models expose hashids and which IDs remain internal.
  • Scaling: CPU cost is negligible for normal requests. Watch serialization of large collections and hot paths; cache computed hashids if needed. There is no DB index on hashid, so lookups should decode and query by integer PK.
  • Failure modes: Missing or misconfigured salt, stale config cache, invalid hashes causing exceptions, salt rotation invalidating URLs, numeric-ID fallback leaking enumeration, and package incompatibility after Laravel upgrades.
  • Ramp-up: One to two hours for a Laravel developer plus test patterns and a short runbook. Low training cost; moderate governance around salt management and dependency ownership.
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.
gmostafa/php-graphql-client
xeviant/paystack
snowsoft/faker
meditationsteps/blogetc
animalyoung/laravel-influxdb
onix-solutions/sms-telera
lonely-lights/prosetta
oxygen/data
oxygen/core
jengo/base
xiloryx/log-collector
a21ns1g4ts/filament-stripe
la-php/laravel-admin
artisan-build/community-prompts
vleroy/smart
ayles-software/laravel-australian-public-holidays
cboxdk/laravel-id-spatie
cboxdk/laravel-id-billing
cboxdk/laravel-id-billing-bridge
simple-as-fuck/php-performance-log