ryangjchandler/laravel-uuid
A lightweight Laravel package that brings UUID support to Eloquent models. It provides a simple trait for generating UUID primary keys and resolving models by UUID, making it easy to use UUIDs in place of auto-incrementing IDs.
Architecture fit. The package is a narrow, single-purpose trait for Eloquent models that assigns a UUID to a model attribute (typically the primary key) on creation. Architecturally it sits cleanly inside Laravel’s model lifecycle — no service providers to configure, no middleware, no schema coupling beyond the column type. For a Laravel-only codebase already standardized on Eloquent, the surface area is minimal: one trait, one boot hook, one Str::uuid() call. That makes it easy to reason about, but it also means the package is essentially a 20-line convenience wrapper around framework primitives. The architectural question is not "does it fit" but "does it earn a dependency."
Integration feasibility. High in isolation: composer require, use UuidTrait; (or equivalent) on the model, change the migration column to uuid/char(36), done. The real friction is downstream: foreign keys referencing UUID PKs must be retyped, route model binding must be verified, JSON/API serialization must be consistent, and any whereIn/join logic on integer IDs needs auditing. Feasibility on a greenfield model is trivial; feasibility on an existing schema with integer PKs and foreign-key webs is a migration project, not a package install.
Technical risk. Low code risk, elevated dependency risk. Key concerns:
HasUuids and HasUlids natively (and HasVersion7Uuids in newer releases). If the target is Laravel 9+, this package is functionally superseded and adds a third-party dependency for zero capability gain.Key questions. (1) What Laravel/PHP versions are supported, and is there a maintained release compatible with our target? (2) Does it support UUIDv7/ordered UUIDs, or only v4? (3) Is UUID the primary key or a secondary column — and does the package force either? (4) Does it integrate with route model binding and getRouteKeyName out of the box? (5) What is the license and maintenance posture versus Laravel’s native HasUuids? (6) Does it handle uuid vs char(36) vs binary(16) storage, and does it expose a hook for binary packing?
Stack fit. Fits a Laravel + Eloquent monolith or modular monolith with PHP 8.x. Does not fit well where non-Laravel services (Go, Node, Python workers) write to the same tables — they must independently generate and agree on UUID format and storage encoding, so an ADR defining "UUIDs are v4, stored as char(36)" (or binary(16)) is a prerequisite. Also poor fit for polyglot or DB-portable schemas where integer PKs are the lowest common denominator.
Migration path. Sequence it deliberately:
HasUuids covers the need. If yes, do not adopt — close the ticket. This is the cheapest decision and should be made first.HasUuids later without touching every model.Compatibility. Verify PHP/Laravel constraint compatibility before pilot; a package with 0 dependents may not have been tested against current framework majors. Check that it doesn’t conflict with native UUID traits if both exist in the codebase (boot-hook ordering can double-generate or override). If the project is on Laravel <9, the package is more defensible but also more likely to be unmaintained.
Sequencing. Decide native-vs-package → wrap in local abstraction → pilot one model → audit FKs and API contracts → expand to new tables → retire or replace the dependency long-term.
Maintenance. Very low day-to-day cost if adopted — no config, no daemon, no background job. The maintenance burden is concentrated in upgrades: because the package has no dependents and appears unmaintained, a Laravel major upgrade may force a fork or replacement. Budget for an exit path (the local wrapper trait) rather than a support contract.
Support. Effectively community-only via GitHub issues with low traffic. No vendor SLA, no security advisory process. Treat as "no support" in the risk register; the mitigation is low coupling, not hope.
Scaling. UUID primary keys change the database’s write profile. Random v4 UUIDs fragment InnoDB B-tree indexes and inflate PK storage (36 bytes as char vs 8 for bigint), which matters at high insert volume or large tables. If scale is a concern, prefer UUIDv7/ULID or binary(16) storage, and confirm the package supports that. This is a database-performance decision the package does not make for you.
Failure modes. (a) Trait omitted on a new model → silent ID drift. (b) Mixed integer/UUID PKs across tables → foreign-key type mismatches and failed migrations. (c) Uniqueness collision — negligible probability but no visible retry logic guarantees it. (d) Upgrade breakage from abandonment. (e) Non-Laravel consumers writing incompatible UUID encodings. (f) Route binding exposing/accepting wrong key format.
Ramp-up. Near-zero for developers already fluent in Eloquent; one line of onboarding. The real onboarding cost is organizational: communicating the "UUID by default" convention, the chosen version/encoding, and the foreign-key rules so new models don’t silently diverge. That convention, not the package, is the durable artifact.
TPM recommendation. Do not treat this as a build-vs-buy decision; it is a build-vs-framework-native decision. Given zero dependents, no visible maintenance, and native HasUuids in modern Laravel, the default recommendation is to use the framework primitive behind a local trait. Adopt this package only if the target framework version predates native support and the package is verified compatible; in all cases, keep the vendor trait behind a one-line abstraction so it can be retired without a rewrite.
How can I help you explore Laravel packages today?