~/docs
Resonate
Resonate
9.x 9.0.0, current 8.x 8.0.0 7.x 7.0.1 6.x 6.2.1 5.x 5.1.2 4.x 4.0.2
Laravel UUID
Toggle sidebar
Laravel UUID
webpatser/laravel-uuid 7.0.1
You are reading the 7.x documentation
The current line is 9.x. Read this page for 9.x

Laravel UUID 7.x

Installation

Install Laravel UUID 7.x, the Laravel integration for webpatser/uuid with Str macros, a HasUuids trait, casts and binary storage.

Laravel UUID is the Laravel integration layer for the UUID library (webpatser/uuid). It adds Str macros, HasUuids and HasBinaryUuids traits, Eloquent casts and migration helpers for binary UUID columns.

Note: This is the 7.x line. It requires Laravel 13 and PHP 8.5 and is no longer the current release line. See Upgrade for the changes from 6.x.

Install

composer require webpatser/laravel-uuid

The service provider Webpatser\LaravelUuid\UuidServiceProvider is registered through Laravel package auto-discovery, and a Uuid alias is registered too (it does not resolve in 7.0.1, use Webpatser\Uuid\Uuid directly). The provider registers the Str macros on boot. There is no config file to publish.

Requirements

  • PHP ^8.5
  • illuminate/support ^13.0 (Laravel 13)
  • webpatser/uuid ^2.0 (installed automatically)

Not using Laravel?

If you do not need the Eloquent traits, casts or Str macros, use the core library directly: UUID library.

What is included

Piece Class
Str macros Webpatser\LaravelUuid\UuidMacros (registered by the service provider)
Facade alias Uuid Webpatser\LaravelUuid\UuidFacade, registered but not usable in 7.0.1; use Webpatser\Uuid\Uuid directly
String UUID keys Webpatser\LaravelUuid\HasUuids
Binary UUID keys Webpatser\LaravelUuid\HasBinaryUuids
Casts Webpatser\LaravelUuid\UuidCast, Webpatser\LaravelUuid\BinaryUuidCast
Migration helpers Webpatser\LaravelUuid\BinaryUuidMigrations

Verify the installation

php artisan tinker
use Illuminate\Support\Str;
use Webpatser\Uuid\Uuid;
 
echo Str::fastUuid(); // random UUID (version 4)
echo Str::fastOrderedUuid(); // time-ordered UUID (version 7)
echo Uuid::v7();

Next steps