matt-daneshvar/eloquent-hashids
Laravel package that adds Hashids support to Eloquent models, hiding auto-increment IDs behind short, reversible hashes. A trait encodes route keys and resolves models from hashids, keeping URLs clean and database IDs private with minimal setup.
Architecture fit. The package is a single Eloquent concern that hooks model lifecycle events to compute and persist a Hashids-encoded value on create. That is idiomatic Laravel: low surface area, no service provider gymnastics, no runtime interception of the query builder. Architecturally it fits cleanly into any Eloquent-based service that needs opaque external identifiers.
Integration feasibility. The blocker is not design, it is the dependency graph. The last release is June 2019 — prior to Laravel 6 LTS GA — so composer.json almost certainly pins illuminate/* to the 5.5–5.8 range and PHP to 7.1/7.2. On Laravel 10/11/12 (PHP 8.1+) composer require will fail resolution. Forcing it with --ignore-platform-reqs or version aliasing is not defensible for a production system.
Technical risk — high, on three independent axes.
hashids/hashids, whose upstream is itself effectively retired and superseded by Sqids. You inherit two unmaintained layers.Key questions to answer before any code is written.
creating only? Bulk insert()/upsert() and raw SQL bypass model events entirely. What is the backfill and null-handling story?update, soft delete/restore, and replica reads?min_hash_length or salt changes post-launch?Stack fit. Appropriate for a Laravel monolith or API service exposing public IDs (URLs, webhooks, partner integrations) without leaking row counts or creation order. Inappropriate if the hashid is expected to provide any confidentiality guarantee.
Migration path — three options, ranked.
app/Models/Concerns/. The implementation is small enough that copying it is cheaper than defending the dependency. Zero composer friction, full control, trivially upgradable to current Laravel.composer.json. Only justified if multiple applications need to share identical behavior and you want centralized fixes.sqids/sqids (the maintained successor) or vinkla/hashids for encoding only, wrapped in your own trait or a custom Eloquent cast. This is the cleanest long-term position.Compatibility checks. Inspect composer.json for illuminate/* and php constraints first — that single file determines whether this is a five-minute spike or a non-starter. Also confirm the Hashids library major version, since v1 and v2 differ in namespace and API, and any vendored code must be rewritten against the version you actually ship.
Sequencing.
Maintenance. Archived means you are the maintainer from day one. Budget it as internal code in your ownership model, not as a third-party dependency on someone else's upgrade calendar.
Support. None. No upstream responsiveness, no CVE channel, no framework-compatibility patches. Security scanners will flag the abandoned transitive dependency indefinitely; plan an allowlist entry or eliminate the dependency.
Scaling. Read path is a plain indexed column — no runtime cost and no N+1 risk. Write path adds one hash computation per insert, negligible. The real operational cost is the backfill on large tables and the lock profile of adding a unique index to a populated table.
Failure modes.
DB::insert(), queue workers writing raw, and data imports produce rows with null hashids, surfacing later as null-pointer errors in routing or serialization.Ramp-up. A mid-level Laravel developer understands the mechanism in under an hour. The cost is not comprehension — it is the decision to permanently own a frozen artifact, and the migration work later when you inevitably replace it.
How can I help you explore Laravel packages today?