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

Uid Laravel Package

symfony/uid

Symfony UID component offers an object-oriented API to generate and work with unique identifiers. Includes ULIDs and UUIDs (v1 and v3–v8), with implementations compatible with both 32-bit and 64-bit systems for consistent, portable IDs.

View on GitHub
Deep Wiki
Context7

Provides an object-oriented API to generate and represent UIDs

Frequently asked questions about Uid
How do I replace Laravel’s Str::uuid() with Symfony UID in my project?
Symfony UID is a drop-in replacement. Replace `Str::uuid()` with `Uuid::v7()` (or `Uuid::v4()` for random) and ensure your database uses binary storage (e.g., `uuid-ossp` in PostgreSQL or `BINARY(16)` in MySQL). Eloquent casts and validation rules remain unchanged.
Which UUID version should I use for Laravel models—v4, v7, or ULID?
For time-sorted data (e.g., audit logs, event sourcing), use **UUIDv7** (chronological) or **ULID** (human-readable timestamps). Use **UUIDv4** for randomness (e.g., sensitive data). ULID is better for shareable links (BASE58 encoding), while UUIDv7 avoids collisions in high-throughput systems.
Does Symfony UID work with Laravel’s Eloquent binary storage for UUIDs?
Yes. Symfony UID supports binary storage out of the box. Configure your migration to use `uuid-ossp` (PostgreSQL) or `BINARY(16)` (MySQL 8+), then use Eloquent’s `Uuid` or `Ulid` casts. This reduces storage overhead by ~50% compared to `CHAR(36)`.
How do I generate BASE58-encoded ULIDs for shareable links in Laravel?
Use `Ulid::generate()->toBase58()`. This encodes ULIDs into URL-safe, compact strings (e.g., `01H5Z9XJQ3K8F7V4T2R1`). Works seamlessly with Laravel API resources and validation rules like `Ulid|base58`.
Will Symfony UID break my existing Laravel 9/10 app if I upgrade to v8.0.9?
No. Symfony UID v8.0.9 is backward-compatible with Laravel 9/10 (PHP 8.1+). The only change is PHP 8.4+ support for Laravel 11. If you’re on Laravel 9/10, stick with Symfony UID v7.4.x. No API or Eloquent changes are required.
How do I mock UUIDs in Laravel tests with Symfony UID?
Use `MockUuidFactory` from the package to generate deterministic UUIDs in tests. For example: `$mockFactory = new MockUuidFactory(); $uuid = $mockFactory->generate();`. This ensures reproducible test IDs without collisions.
Does Symfony UID support SQLite for UUID/ULID storage?
Yes, but you’ll need the `pdo_sqlite` extension with UUID/ULID support (e.g., via SQLite extensions like `sqlite3_uuid`). Store UUIDs as `BLOB` and ULIDs as `TEXT`. Symfony UID’s API remains consistent across databases.
What’s the performance impact of using binary vs. CHAR(36) storage for UUIDs in Laravel?
Binary storage (`BINARY(16)`) reduces UUID size by ~50% (16 bytes vs. 36 chars) and improves indexing. Benchmarks show ~20–30% faster queries in PostgreSQL/MySQL. For ULIDs, binary storage isn’t natively supported—use `TEXT` with BASE58 encoding for compactness.
Can I migrate from auto-increment IDs to UUIDs in Laravel without downtime?
Yes. Use a **two-phase migration**: 1) Add UUID columns (nullable) to existing tables, 2) Backfill UUIDs for new records, then 3) Drop the auto-increment column. Tools like `laravel-scout` or custom scripts can help sync legacy data.
Are there alternatives to Symfony UID for Laravel UUID/ULID generation?
Alternatives include `ramsey/uuid` (UUIDs only), `paragonie/ulid` (ULIDs only), or Laravel’s native `Str::uuid()`. However, Symfony UID is the most **feature-complete** option, supporting **all UUID versions (v1/v3–v8), ULIDs, RFC 9562, BASE58, and binary storage**—making it ideal for Laravel’s ecosystem.
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