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

Sqids For Laravel Laravel Package

guava/sqids-for-laravel

Generate short, YouTube-style unique IDs from numbers in Laravel. This package wraps Sqids with a facade, configuration, validation rules, and Eloquent helpers so you can encode and decode IDs cleanly across your app.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Public identifier strategy (a product decision, not an engineering detail): Whether order numbers, invoice references, user profiles, and share links show /orders/1042 or /orders/k3Rt9z in URLs, APIs, and emails. This package makes "clean, non-sequential-looking URLs" a cheap, reversible feature choice rather than a data-model overhaul.
  • Build vs. buy: The alternative is hand-rolling encode/decode, alphabet config, blocklists, model traits, and route-binding overrides — then owning that code forever. This is a narrow, well-understood utility; a Laravel-native wrapper (facade, publishable config, HasSqids trait, validation rule) is a reasonable buy if the maintenance and supply-chain profile are acceptable.
  • Roadmap / platform currency: Release 1.2.0 adds Laravel 12 support. That supports a "keep the dependency through the Laravel 12 upgrade" call and removes a pin-to-unmaintained-package risk during migration. Note 1.1.x caps below Laravel 12, so the version constraint is itself a roadmap input.
  • Feature scoping: Unlocks shareable links, referral/invite-style codes, nested resource tokens (encode([$tenantId, $orderId])), and cleaner API resource IDs — features that would otherwise need custom encoding work or a UUID/ULID migration.
  • Identifier semantics decision: Sqids is reversible obfuscation, not encryption. Appropriate where the requirement is "don't make IDs obviously sequential"; inappropriate where the requirement is "IDs must be unguessable." This distinction determines whether the package is on the roadmap at all, and it must be settled before any customer-facing commitment.
  • Data-model decision: Encode at the presentation/API boundary (resource classes, getRouteKey()) rather than replacing primary keys. Foreign keys stay numeric, no data migration, and the change is reversible — the cheaper and lower-risk product choice.
  • API contract decision: Adopting this changes the type of IDs in public API responses from integer to string. That is a breaking change for client SDKs and OpenAPI schemas, so it belongs in release planning and deprecation/comms, not just a sprint ticket.

When to Consider This Package

Consider it when:

  • The product is a Laravel application (10/11 today, 12 planned or in progress) and needs short, reversible, non-sequential-looking identifiers in URLs, APIs, or share links.
  • Internal integer IDs must stay private-ish at the UX layer while remaining the real primary/foreign keys — encoding at the boundary is acceptable and a data migration is not wanted.
  • The team wants a small, Laravel-idiomatic integration (facade, config, model trait, route binding, validation rule) instead of maintaining bespoke Sqids/Hashids code.
  • IDs are needed on greenfield endpoints or low-risk resources where a short spike validates behavior, and existing authorization checks remain the actual access control.
  • Laravel 12 compatibility matters — 1.2.0 explicitly widens illuminate/* constraints with no config or trait signature changes.

Look elsewhere when:

  • The requirement is globally unique, distributed, or sortable IDs (UUIDv7/ULID), or IDs must be generated without a central integer to decode.
  • The identifier must be unguessable or a security boundary — capability tokens, password resets, signed download URLs. Sqids is obfuscation; pair it with Laravel signed middleware or a real token scheme, and never use it for authorization.
  • Clients must not be able to decode identifiers — alphabet and min_length are enough to reverse them.
  • The team needs vendor-backed/commercial support, strict length guarantees at very large dataset sizes, or a visibly active release cadence — this is a small community dependency with zero dependents and a low score, so treat it as a supply-chain risk with a documented fallback to the underlying sqids/sqids library.
  • Configuration is expected to change after launch: altering the alphabet or min_length invalidates every previously issued ID (emails, bookmarks, third-party callbacks), so environments where that value is not effectively immutable are a poor fit.
  • The app relies on runtime config mutation (e.g., per-request alphabets under Octane) — the encoder is a singleton resolved from config, so that pattern silently won't work.

How to Pitch It (Stakeholders)

For executives: This is a small, low-cost Laravel integration that lets us ship short, clean, non-sequential public IDs — /orders/k3Rt9z instead of /orders/1042 — without building or maintaining custom encoding logic. It supports obvious product wins: tidier URLs, less exposure of internal database numbering, and faster delivery of shareable-link and public-reference features. The 1.2.0 release adds Laravel 12 support, so it stays viable through our framework upgrade rather than becoming migration debt. Cost is a targeted dependency with a narrow responsibility and negligible runtime overhead (CPU-local, no extra DB or network hops). One thing to be explicit about at leadership level: this is a UX and obfuscation utility, not a security control. Encoded IDs can be decoded by anyone who knows the configuration, so access to sensitive records must continue to be enforced by our authorization layer — we should not let "the ID looks random" be mistaken for "the record is protected." Second caveat: this is a small, community-maintained package, so we pin it, keep it in the dependency inventory, and retain a low-cost fallback.

For engineering: Buy over build. The package is a thin Laravel wrapper over Sqids — facade, publishable config (alphabet, min_length, blocklist), auto-discovered provider, a HasSqids trait for model keys and route binding, and a validation rule. That's roughly the code we'd otherwise write and then own. Adoption path is low-risk: pin ^1.2, confirm Composer constraints against our Laravel/PHP matrix (1.1.x will not resolve on Laravel 12), spike one low-risk endpoint, encode at the API/resource boundary rather than in model accessors, validate and decode inbound sqids, and keep authorization independent of ID format. Watch four things: (1) decode() returns an array and returns [] on invalid input — treat that as a 404, never pass it to find(); (2) config drift across environments, since config:cache bakes in the alphabet and changing it later is a breaking change for every issued ID; (3) the package is community-maintained with zero dependents, so pin it and keep a fallback plan to call the underlying Sqids library directly; (4) switching route IDs is a public API contract change — plan dual read paths, updated route-model binding, and refreshed API docs/OpenAPI schemas (ID becomes a string) before broad rollout. Ongoing maintenance is essentially dependency bumps.

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.
abbasudo/artisan-route
mirvan/ippanel
ignibyte/aic-framework
glavweb/data-schema-bundle
glavweb/datagrid-bundle
tacticmedia/scim-server
uni-method/frame
neika-ai/sdk
adachsoft/php-code-style
pharaonic/laravel-notification-dependencies
beautinow/translug
dev-brainiac/bot-cloaked
octoberrain/html
octoberrain/extension
octoberrain/exception
octoberrain/contracts
adachsoft/api-version-bundle
cgv/localized-resource
noith/settings
kda/laravel-package