Weave Code
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

Model Uuid Laravel Package

fahriztx/model-uuid

Laravel/PHP trait to add automatic UUIDs to Eloquent models. Generates a UUID when creating records and supports using UUIDs as primary keys or additional identifiers, reducing reliance on auto-increment IDs and easing integration across systems.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Scalable Identity Management: Enables globally unique, distributed-friendly primary keys (UUIDs) for microservices, multi-tenant SaaS, or systems requiring cross-database consistency.
  • Roadmap Alignment: Justifies long-term architecture shifts (e.g., migrating from auto-increment IDs to UUIDs) by providing a low-friction implementation path.
  • Build vs. Buy: Avoids reinventing UUID handling (generation, validation, migration) while maintaining control over customization (e.g., UUID version, naming conventions).
  • Use Cases:
    • Data Migration: Seamlessly transition legacy systems to UUIDs without downtime (via uuid column migration helpers).
    • Security/Compliance: Replace sequential IDs with UUIDs to obscure internal data structures (e.g., for audit trails or PII handling).
    • Performance Optimization: Distributed systems where auto-increment IDs cause bottlenecks (e.g., sharded databases).
    • User-Facing APIs: Generate shareable, human-readable UUIDs (e.g., user-abc123 instead of id=42) for URLs or client-side references.

When to Consider This Package

Adopt if:

  • Your Laravel app requires distributed primary keys (e.g., multi-region deployments, Kubernetes, or serverless).
  • You’re migrating from auto-increment IDs to UUIDs and need minimal refactoring (e.g., fillable, casts, and primaryKey auto-configuration).
  • Security/privacy is a priority (e.g., UUIDs prevent ID enumeration attacks or expose less internal structure).
  • Your team lacks bandwidth to build UUID handling from scratch but needs customization (e.g., UUID version 7 for timestamps, hyphenated formats).
  • You’re using Laravel 10+ and want to avoid manual UUID generation libraries (e.g., ramsey/uuid) with extra setup.

Look elsewhere if:

  • You need high-performance UUID generation (this package uses Laravel’s default Str::uuid(), which may not be optimized for bulk inserts).
  • Your primary key strategy is not UUID-based (e.g., ULIDs, Snowflakes, or composite keys).
  • You require advanced UUID features (e.g., sorting, version 7 support, or custom hashing) beyond basic CRUD operations.
  • Your database doesn’t support UUID natively (e.g., SQLite without extensions) or you’re using a non-Laravel framework.
  • You’re in a highly regulated environment where MIT-licensed packages require internal review (though MIT is permissive, some orgs mandate audits).

How to Pitch It (Stakeholders)

For Executives: *"This package lets us replace fragile auto-increment IDs with UUIDs—globally unique, secure, and scalable—without rewriting our entire database layer. It’s a drop-in solution for:

  • Future-proofing: Avoids ID collisions in distributed systems (critical for our multi-cloud roadmap).
  • Security: UUIDs hide internal data structures, reducing attack surfaces (e.g., for our healthcare/finance clients).
  • Cost savings: Eliminates custom UUID logic development (estimated 2–3 dev weeks) while keeping flexibility. The MIT license and active maintenance (last release: March 2025) make it a low-risk choice. We can pilot it in our [Non-Critical Module] before full adoption."*

For Engineering: *"This package abstracts UUID handling in Laravel with these key benefits:

  • Zero-config for basic use: Auto-generates UUIDs, handles migrations, and works with Eloquent out of the box.
  • Customizable: Override UUID version, format, or generation logic via service providers (e.g., switch to v7 for sortable timestamps).
  • Migration-friendly: Includes helpers to add UUID columns to existing tables with minimal downtime.
  • Performance: Uses Laravel’s built-in Str::uuid() (optimized for most use cases); we can swap the underlying generator later if needed. Tradeoffs:
  • No built-in bulk-insert optimization (but we can extend it).
  • Requires Laravel 10+ (aligns with our stack). Proposal: Use this for [Module X]’s new tenant isolation layer, then evaluate for broader adoption after the MVP."*

For Developers: *"Here’s how this simplifies UUID adoption:

  1. Install: composer require fahriztx/model-uuid.
  2. Configure: Add use HasUuid; to your model and optionally tweak UUID settings in AppServiceProvider.
  3. Done: All new models get UUIDs automatically, and migrations are handled via Schema::uuid(). Example:
use FAHRIZTX\ModelUuid\HasUuid;

class User extends Model {
    use HasUuid; // Auto-configures primaryKey, casts, and fillable
}

Extensible: Need UUIDv7? Override the generateUuid() method. Want hyphens? Configure it in the service provider. Docs: GitHub README is minimal but clear—we can add internal examples for our stack."*

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.
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours