tonysm/globalid-laravel
GlobalID for Laravel brings Rails-style global identifiers to Eloquent models. Generate and parse stable gid:// strings for any model record, create signed GlobalIDs for secure expiration, and use them in jobs, URLs, and APIs without exposing raw IDs.
composer require tonysm/globalid-laravel, then publish the config (php artisan vendor:publish --tag="globalid-config" — check the package README for the exact tag in 1.5.0, since the locator config shape changed in this release).config/globalid.php first. In 1.5.0 the locator registry is the single source of truth: a GID can only be decoded back to a model that has an explicitly registered locator. Read the locators array before writing any code, because an empty/partial registry is now a hard failure rather than a silent fallback.APP_KEY is set in every environment. GIDs are encrypted payloads; a missing or mismatched key means every encoded string from another environment is undecodable.Post, then in an ApiResource return 'id' => GlobalId::encode($this), and in the controller accept the GID, decode it, and 404 on failure. That single round-trip exercises encoding, config registration, and decoding — if all three work, the rest of the package is variations on the same theme.GlobalId::decode() path for endpoints that take a GID inside a request body rather than the URL.handle(), and re-fetch the model. This keeps the payload small and avoids serialising a stale Eloquent instance, and it survives the model being updated between dispatch and execution.uuid-keyed model, a morph aliased model, or a composite key. The locator is where you own the model → id and id → model mapping, so this is also the seam for multi-tenant scoping — resolve the model inside the tenant context in find() rather than globally.encode/decode, and add one explicit test per registered locator asserting an unknown-model GID fails. That test is what catches the 1.5.0 behaviour change for you.GlobalId::encode() call sites against the config before upgrading, and grep for morph maps.APP_PREVIOUS_KEYS. Decode with the current key list, but remember a re-encode after rotation produces a different string: any GID embedded in a cached response, a previously sent email, or a stored ETag will still decode but won't match a freshly generated one. Compare on decoded class plus primary key, never on the GID string. Also check whether the encoded form is deterministic — if it isn't (random IV), GIDs are unsuitable as cache keys, dedupe keys, or anything requiring stable equality.GlobalId in a service, so route binding and any internal decode paths pick up your logic too.How can I help you explore Laravel packages today?