ramsey/uuid is a PHP package for creating and handling universally unique identifiers. It installs via Composer and documents RFC-style UUID versions plus storage and testing helpers.
Overview
ramsey/uuid is a PHP library focused on generating and working with UUIDs (universally unique identifiers). It is distributed as a Composer dependency that projects import into application code.
The user guide covers standard RFC 9562 (formerly RFC 4122) UUID versions, including time-based, name-based, random, reordered time, Unix epoch, and custom formats. It also describes GUID handling, nonstandard variants, and customization through codecs, calculators, validators, and factory replacement.
Documentation explains storing UUIDs in databases as strings or bytes, using them as primary or unique keys, and related insertion and sorting behavior. Testing sections describe injecting fixed UUIDs, mocking interfaces, and controlling static generation in tests.
Installation is documented through Composer. Upgrade guides exist for moving between major library generations when dependencies require it.
Key features
- Multiple RFC UUID versions
- GUID support
- Custom codecs and factories
- Database storage guidance
- Primary and unique key usage
- Validators and calculators
- Composer installation
- Testing and mocking helpers
Use cases
- Primary keys in PHP apps
- Distributed unique IDs
- Name-based deterministic UUIDs
- Test-controlled identifier output