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
- Quick Start: the
Strmacros, theUuidlibrary and validation. - Eloquent Models: UUID keys, casts and route model binding.
- Binary Storage: 16-byte columns, migration helpers and conversion.
- UUID library: the full UUID API.