symfony/polyfill-uuid
Symfony Polyfill for UUID brings uuid_* functions to PHP environments that don’t have the uuid extension installed. It lets applications use common UUID helpers consistently across PHP versions, matching Symfony’s polyfill approach and staying lightweight and MIT licensed.
Str facade, Eloquent models, and migrations, eliminating environment-specific UUID inconsistencies. Aligns with Laravel’s "write once, run anywhere" philosophy by providing a consistent UUID API across PHP versions (5.6–8.0+) and deployment environments.ext-uuid if available, enabling frictionless PHP version upgrades (e.g., 7.4 → 8.0+) without code changes. Reduces technical debt in long-lived applications by future-proofing UUID logic.random_bytes(), meeting regulatory requirements (HIPAA, PCI DSS, GDPR) without external dependencies. Ideal for audit trails, financial systems, and healthcare applications where deterministic, dependency-free UUIDs are critical.ramsey/uuid, voku/uuid, or manual implementations) with zero code changes. Example:
// Before (custom or ramsey/uuid)
$uuid = \Ramsey\Uuid\Uuid::uuid4()->toString();
// After (polyfill)
$uuid = Str::uuid(); // or uuid_generate_v4()
Str::uuid(), Eloquent models, and migrations, ensuring consistency across the stack. Example migration:
$table->uuid('id')->default(uuid_generate_v4());
symfony/polyfill bundle, reducing integration effort to a single Composer install. No runtime configuration or environment-specific setup required.ext-uuid due to pure PHP implementation of UUID generation.ext-uuid for PHP 8.0+ if performance is critical, as the polyfill automatically defers to native functions.random_bytes() for cryptographic security, which may fail in low-entropy environments (e.g., Docker without --cap-add=SYS_RANDOM, CI/CD pipelines, or air-gapped systems).--cap-add=SYS_RANDOM to Docker containers.random_bytes() entropy in CI/CD pipelines (e.g., using openssl_random_pseudo_bytes as a fallback).ramsey/uuid for additional validation or use a custom entropy source.ramsey/uuid (12K stars) for advanced use cases, though it adds ~50KB to the bundle. Evaluate trade-offs based on feature requirements vs. bundle size.ext-uuid be mandated for PHP 8.0+ deployments to eliminate polyfill overhead?ramsey/uuid or another UUID library that could conflict or require migration?random_bytes() may fail?Str facade, Eloquent ORM, and migrations. Reduces technical debt by standardizing UUID generation across the stack.ramsey/uuid, voku/uuid, or manual implementations) using tools like grep or IDE search.composer.json:
"require": {
"symfony/polyfill-uuid": "^1.36"
}
composer update symfony/polyfill-uuid --with-dependencies.ramsey/uuid).Ramsey\Uuid\Uuid::uuid4() with Str::uuid() or uuid_generate_v4().$table->uuid('id')->default(uuid_generate_v4()).random_bytes() entropy in CI/CD pipelines (e.g., using random_bytes() fallback logic).ext-uuid in production to leverage native performance. The polyfill will automatically defer to native functions.ext-uuid where feasible.ramsey/uuid) in favor of the polyfill, unless advanced features are required.v1.36.0).ext-uuid. Automatically falls back to native functions if available.symfony/polyfill bundle or other common libraries. Potential conflict with ramsey/uuid if both are used; resolve by choosing one standard.random_bytes() or use fallbacks).ext-uuid (if available).ramsey/uuid) where not required for advanced features.ext-uuid for PHP 8.0+ environments toHow can I help you explore Laravel packages today?