Weave 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
Laravel Eloquent Uuid

Laravel Eloquent Uuid Laravel Package

astrotomic/laravel-eloquent-uuid

Astrotomic's Laravel Eloquent UUID package adds UUID primary key support to your Eloquent models with minimal configuration. Generate unique, non-sequential identifiers for safer, distributed-friendly records while keeping familiar Laravel model behavior.

View on GitHub
Deep Wiki
Context7

At a glance

Frequently asked questions about Laravel Eloquent Uuid
How do I install astrotomic/laravel-eloquent-uuid?
Install it with Composer by requiring astrotomic/laravel-eloquent-uuid; Laravel's package auto-discovery registers the service provider, so no manual wiring is needed. Because 1.5.0 targets Laravel 8 and 9 on PHP 7.4 through 8.1, run composer require on a host that already meets those constraints. If Composer rejects the install, your framework or PHP version is the blocker, not the package itself.
Which Laravel and PHP versions does this package support?
Release 1.5.0 supports Laravel 8.x and 9.x on PHP 7.4, 8.0, and 8.1. Laravel 6, Laravel 7, and PHP 7.3 were dropped in this release, realigning the package with the framework's own support cadence. Applications still on those older versions must stay on 1.4.x until the framework is upgraded.
How do I add UUID primary keys to an Eloquent model with this package?
The package is a drop-in Composer dependency, so you enable UUID keys per model with minimal configuration rather than rewriting your persistence layer. The model's table still needs a UUID primary key column, and any foreign keys pointing at it must use the same UUID type. Eloquent's familiar model behavior otherwise stays the same.
Can I use astrotomic/laravel-eloquent-uuid with Laravel 6 or Laravel 7?
No. Version 1.5.0 is not installable on Laravel 6 or 7 because Composer's solver will reject it against the host framework constraint. That is a safe install-time failure rather than runtime breakage, but it means there is no package migration path, only a framework upgrade. Pin to 1.4.* if you must stay on those versions for now.
Is 1.5.0 a breaking change even though it is a minor release?
Yes, functionally: dropping PHP 7.3, Laravel 6, and Laravel 7 are breaking changes shipped in a minor bump. Any ^1.0 constraint can therefore resolve to 1.5.0 on the next composer update. Pin your lockfile and audit every service still on ^1.0 before updating.
Do I need to change my database migrations to use UUIDs?
Yes. The primary key column must be a UUID-compatible type instead of an auto-incrementing integer, and any foreign keys referencing it must use the same type and length. Plan the migration before enabling the package on existing tables, since converting populated tables is a data migration rather than a config change.
Does this package work with Eloquent relationships and route model binding?
UUID keys are non-incrementing strings, so relationships work as long as foreign key columns are UUID-typed and models are configured for string keys. Route model binding then resolves by the UUID instead of an integer ID. Verify with your own tests, since 1.5.0 introduces no new extension points or lifecycle hooks.
How do I test Eloquent models that use UUID primary keys?
Use RefreshDatabase or DatabaseTransactions as usual; the only difference is asserting against string keys rather than integers. Add a CI matrix leg on PHP 8.1 so deprecation output from the package or its transitive dependencies is caught early. Run your full suite after bumping to ^1.5 and scan logs for E_DEPRECATED notices.
Will this package cause PHP 8.1 deprecation warnings in my logs?
Possibly. 1.5.0 is the first release with PHP 8.1 support, so expect E_DEPRECATED output from implicit nullable parameters, ${var} interpolation, or strlen(null) in the package or its dependencies. Severity is low, but it can pollute logs and break strict test suites. Keep deprecation reporting enabled in CI and watch for a follow-up patch.
What are the alternatives to astrotomic/laravel-eloquent-uuid?
Laravel 9 ships a native HasUuids trait, which removes the need for a third-party package on that version. On Laravel 8 you can also implement UUID keys manually with a model boot callback and a uuid column. Compare maintenance signals such as Laravel 10 and PHP 8.2 commitments before choosing, since 1.5.0 drops older framework versions in a minor release.
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.
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core