goldspecdigital/laravel-eloquent-uuid
Pros:
ramsey/uuid under the hood, which is a well-optimized library for UUID generation and comparison.Cons:
INT) and may impact indexing performance in some databases.config/app.php).uses \GoldSpecDigital\LaravelEloquentUuid\UuidTrait).$table->uuid('id')->primary()).ramsey/uuid (v4 by default) and Laravel 7.0+ (tested up to Laravel 10).doctrine/dbal.CAST(id AS CHAR) in SQL).ramsey/uuid’s v4 generation).CHAR(36) vs. BINARY(16))?hasOne, belongsTo, etc.).where, find, first, and raw queries.BINARY(16) or CHAR(36) with custom collation.ramsey/uuid for generation).UNIQUEIDENTIFIER but may need type casting in queries.ramsey/uuid and update composer.json:
composer require goldspecdigital/laravel-eloquent-uuid ramsey/uuid
AppServiceProvider to register the package.UuidTrait and update migrations:
Schema::create('users', function (Blueprint $table) {
$table->uuid('id')->primary();
// ...
});
id INT, uuid UUID) during transition.$table->uuid('user_id')->constrained()).CAST(id AS CHAR)).Str::uuid() or Uuid::generate() for dynamic UUIDs in legacy logic.intval() or cast_to_int() logic with UUID-aware validation.settings, logs, or media that have minimal impact if migrated incorrectly.users, orders, or transactions until the end to minimize risk./v1/users/{id} vs. /v2/users/{uuid}).goldspecdigital/laravel-eloquent-uuid for breaking changes (low risk; MIT license).ramsey/uuid as needed (security patches only).ramsey/uuid).CHAR UUIDs (use BINARY(16) or BINARY(36)).telescope or `larHow can I help you explore Laravel packages today?