Weave Code
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

Provides polyfills for the uuid extension, adding uuid_* functions on PHP versions where the extension isn’t available. Part of Symfony’s Polyfill suite; lightweight drop-in to improve portability across environments.

View on GitHub
Deep Wiki
Context7

Symfony polyfill for uuid functions

Frequently asked questions about Polyfill Uuid
How do I use symfony/polyfill-uuid in Laravel for Eloquent model IDs?
Simply define your model ID as UUID in the migration using `$table->uuid('id')`—the polyfill automatically handles generation via `uuid_generate_v4()`. No extra code is needed. It works seamlessly with Laravel’s Eloquent ORM, including factories and seeders.
Will this package work with Laravel 5.7 or older versions?
Yes, the package supports Laravel 5.7+ and PHP 5.6–8.0+. However, for Laravel 5.7, ensure your `composer.json` explicitly requires `symfony/polyfill-uuid` as a dependency. No additional configuration is needed for basic UUID functionality.
Does symfony/polyfill-uuid replace ramsey/uuid in Laravel?
Yes, it’s a drop-in replacement for basic v4 UUID generation in Laravel. If you’re using `ramsey/uuid` only for v4 UUIDs, switch to this polyfill to reduce bundle size (~50KB lighter). For advanced UUID features (e.g., version 1/3/5), keep `ramsey/uuid` alongside it.
How does performance compare to PHP’s native ext-uuid?
The polyfill introduces 10–30% latency compared to `ext-uuid` due to its pure PHP implementation. For high-throughput Laravel APIs (e.g., generating >10K UUIDs/sec), benchmark and consider enabling `ext-uuid` in PHP 8.0+ or batching UUID generation.
Can I use this polyfill in Docker or CI/CD environments without entropy issues?
Yes, but ensure Docker containers have `--cap-add=SYS_RANDOM` to avoid low-entropy UUIDs. In CI/CD, test `random_bytes()` entropy or fall back to `openssl_random_pseudo_bytes()` for critical systems. The polyfill defaults to RFC 4122-compliant v4 UUIDs using `random_bytes()`.
Does this package support Laravel’s Str::uuid() helper?
Absolutely. The polyfill integrates natively with Laravel’s `Str` facade, so `Str::uuid()` will generate RFC 4122-compliant v4 UUIDs automatically. No additional setup is required—just ensure the package is installed via Composer.
What if my Laravel app already uses custom UUID logic or ramsey/uuid?
Replace custom `uuid_generate_v4()` calls with the polyfill’s functions (e.g., `uuid_generate_v4()`). If using `ramsey/uuid`, you can safely remove it for basic v4 UUIDs, but keep it for advanced features like version 1/3/5 or validation. The polyfill won’t conflict with existing code.
Is symfony/polyfill-uuid secure for HIPAA or PCI DSS compliance?
Yes, it generates cryptographically secure v4 UUIDs using `random_bytes()`, meeting RFC 4122 and compliance requirements for HIPAA, PCI DSS, and SOC 2. However, validate `random_bytes()` entropy in your environment (e.g., Docker/CI) to ensure no weak randomness affects compliance.
How do I install this in a Laravel project?
Run `composer require symfony/polyfill-uuid` in your project root. Laravel’s autoloader will handle the rest—no manual configuration is needed. The polyfill activates automatically when `uuid_*` functions are called, like in migrations or Eloquent models.
What Laravel versions and PHP versions are officially supported?
The package supports Laravel 5.7+ and PHP 5.6–8.0+. For PHP <5.6, use Symfony’s older polyfill versions (e.g., `~1.10`). It’s backward-compatible with Laravel’s Str facade and Eloquent, so no breaking changes are expected in supported versions.
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.
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope
anil/file-picker
broqit/fields-ai