laravel-json-api/hashids
Adds Hashids support to Laravel JSON:API, encoding resource IDs into short, obfuscated strings and decoding them on request. Configure salt, length, and alphabet while keeping numeric database keys hidden behind spec-compliant JSON:API routes and relationships.
laravel-json-api as the API layer. Adopting it reinforces JSON:API compliance as a deliberate standard rather than ad-hoc REST style.laravel-json-api, need spec-compliant opaque string resource IDs quickly, want to retain integer primary keys for performance, and the threat model is casual enumeration or competitive intelligence rather than determined adversaries.laravel-json-api, and the underlying Hashids library.laravel-json-api; you need genuine unguessability or non-reversibility; salt rotation or per-tenant/per-environment isolation is a hard requirement; supply-chain policy blocks tiny dependencies; multiple services must independently resolve the same public ID; or your API surface is mixed and only one surface would use the encoder.Executives: This is a small configuration decision that stops our public API from advertising how many customers, orders, or records we have, and prevents casual walking of our data by incrementing URLs. It keeps database performance intact with integer keys internally while presenting opaque IDs externally, and it aligns with the JSON:API standard if we have adopted it. The important timing point is that changing ID formats after launch breaks clients, links, caches, and integrations, so it is materially cheaper to decide before public launch. Recommendation: adopt only if laravel-json-api is already committed, and vendor the tiny adapter rather than treating a five-star, zero-dependent package as strategic infrastructure. Position it as anti-enumeration and obfuscation, not security or authorization.
Engineering: Register the encoder at the laravel-json-api boundary, keep the salt in the secrets manager, pin minimum length in config, and document IDs as opaque strings in the API contract. Test encoding and decoding across resource objects, relationship identifiers, relationship endpoints, create/update responses, pagination links, and error documents. Verify behavior under config:cache, route model binding, authorization policies, caches, logs, exports, and support tooling. Pilot one low-risk resource first, then expand only after frontend, cache, analytics, and support impacts are owned. Treat salt rotation as a versioned API event, not a config change, and name an owner for the vendored source. If non-reversible or distributed IDs become a requirement later, the migration path is UUIDv7/ULID — which is exactly why this ID-format decision should be made deliberately now.
How can I help you explore Laravel packages today?