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
Polyfill Uuid

Polyfill Uuid Laravel Package

symfony/polyfill-uuid

Symfony polyfill for the PHP uuid extension. It provides the uuid_* functions on PHP installations without ext-uuid, so applications and libraries can use UUID helpers without requiring the extension. Lightweight, MIT-licensed, and maintained by Symfony.

View on GitHub
Deep Wiki
Context7

Symfony polyfill for uuid functions

Frequently asked questions about Polyfill Uuid
What is symfony/polyfill-uuid used for in Laravel?
symfony/polyfill-uuid provides the uuid_* functions for PHP environments that do not have the uuid extension installed, so Laravel apps can generate UUIDs consistently across versions. It is a lightweight, MIT-licensed Symfony polyfill that follows the same approach as other Symfony polyfills. In Laravel it is typically available through the symfony/polyfill bundle and supports common UUID helpers without runtime configuration.
How do I install symfony/polyfill-uuid in a Laravel app?
Install it with composer require symfony/polyfill-uuid. Many Laravel applications already receive it through Symfony's polyfill bundle, so a separate install may not be necessary. After installation, the uuid_* functions are available when ext-uuid is absent, with no additional configuration required.
Does symfony/polyfill-uuid work with Laravel Str::uuid() and Eloquent?
Yes, the polyfill is designed to integrate with Laravel's Str facade, Eloquent models, and migrations. It provides the uuid_* functions that UUID helpers rely on and helps keep UUID output consistent across the stack. The evaluation notes zero code changes for simple v4 UUID use cases.
Which PHP and Laravel versions does symfony/polyfill-uuid support?
The evaluation lists support for PHP 5.6 through 8.0+ and Laravel 5.7+. It is backward compatible with recent versions and automatically defers to native ext-uuid when available. Always confirm your project's Composer constraints before upgrading.
Does symfony/polyfill-uuid replace ramsey/uuid?
The polyfill is not a full replacement for ramsey/uuid; it focuses on basic RFC 4122 v4 UUID generation through uuid_* functions. It can replace simple custom UUID logic or uuid4 calls where only v4 output is needed. For v1, v3, v5, custom namespaces, or validation, use ramsey/uuid instead.
Is symfony/polyfill-uuid secure for production UUID generation?
It generates RFC 4122-compliant v4 UUIDs using random_bytes(), which is suitable for audit trails and compliance-sensitive systems when PHP's CSPRNG is healthy. Security therefore depends on the deployment environment providing sufficient entropy. Test random_bytes() in Docker, CI/CD, and air-gapped systems before relying on it for critical identifiers.
How does symfony/polyfill-uuid performance compare to native ext-uuid?
The pure PHP implementation can add roughly 10–30% latency compared with native ext-uuid. The polyfill automatically defers to ext-uuid when the extension is available, so enabling it on PHP 8.0+ removes that overhead. Benchmark if your application generates more than about 10K UUIDs per second.
Can I use uuid_generate_v4() in Laravel migrations with this polyfill?
The TPM example shows using $table->uuid('id')->default(uuid_generate_v4()) in a Laravel migration. The polyfill supplies uuid_* functions in environments without ext-uuid, so verify the helper is available where migrations run. For portable schemas, also consider generating UUIDs in application code.
What happens if random_bytes() fails in Docker or CI/CD?
Because the polyfill relies on random_bytes(), UUID generation can fail when the environment has low entropy. In Docker, add --cap-add=SYS_RANDOM where appropriate, and test entropy in CI/CD pipelines. For critical systems, pair with ramsey/uuid or use a validated custom entropy source.
Does symfony/polyfill-uuid support UUID v1, v3, v5, or validation?
No, the polyfill only supports basic v4 UUID generation and does not provide v1, v3, v5, custom namespaces, or validation. Use ramsey/uuid if you need those advanced features, accepting the larger bundle size. For simple v4 identifiers, the polyfill stays lightweight and dependency-free.
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.
thomas-0816/doctrine-dbal-duckdb
moyisoft/laravel-admin
oxygen/mod-pages
oxygen/mod-import-export
oxygen/mod-media
ksoft/laravel-contentbuilderjs
ourgoldpackages/exchange
mikkimike/laravel-exchange1c
wandesnet/mercadopago-laravel
tsfcorp/email
larafony/core
laravel-enso/currencies
tartan/laravel-online-payment
gam/laravel-sat-catalogs
cloudcreativity/laravel-stripe
abdulelahragih/querybuilder
wedevbr/celcoin-laravel
surazdott/nepali-date
devsquad-cockpit/laravel
coding-socks/laravel-upload-handler