ramsey/uuid

A PHP library for generating and working with UUIDs

Library
Composer
v4.9.3
12,637stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
68/100Good
Development Activity40
Maintenance60
Community72
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
78/100Good
Architecture82
Code Quality86
Innovation62
Learning Curve82

ramsey/uuid is the de facto standard PHP library for generating and working with universally unique identifiers. It implements every UUID version defined in RFC 4122 (time-based, name-based, random, and version 6/7/8 variants) plus several non-standard GUID formats used by other systems such as Microsoft’s COM.

Beyond generation, the library provides validation, comparison, and codec support for converting UUIDs between string, binary, and numeric representations, along with a pluggable FeatureSet/provider architecture that lets consumers swap in custom random-number, time, or node providers — useful for testing or specialized environments.

What You Get

  • Generation of UUID versions 1 through 8 as defined by RFC 4122, including the newer time-ordered v6/v7
  • Support for non-standard GUID formats (e.g. Microsoft COM-style GUIDs) via the Guid/Nonstandard namespaces
  • Validation and comparison utilities for checking and comparing UUID values
  • Codec support for converting UUIDs between string, binary, and big-integer numeric representations
  • A pluggable FeatureSet/provider architecture for swapping random-number, time, and node providers

Common Use Cases

  • Generating primary keys or public-facing identifiers for database records instead of sequential integers
  • Validating UUID-formatted input in API request handlers
  • Generating deterministic, name-based UUIDs (v3/v5) for reproducible identifiers derived from a namespace and name
  • Interoperating with Microsoft COM-style GUIDs in legacy or cross-platform integrations

Under The Hood

Architecture - The library centers on Uuid.php/UuidFactory.php, which delegate actual generation logic to a Generator/ namespace (separate generators per UUID version/strategy) and represent field data through Fields/ and Rfc4122/ for RFC-compliant UUIDs versus Guid//Nonstandard/ for non-standard variants. Codec/ and Converter/ handle serialization between string, binary, and numeric formats, while Builder/ assembles the correct concrete UUID class based on the requested version, and Validator/ centralizes format-checking logic used across the library.

Tech Stack - The library depends on brick/math for arbitrary-precision integer arithmetic (needed to correctly represent 128-bit UUID values without precision loss) and the sibling ramsey/collection package for typed collection support, requiring PHP 8.0+. Its FeatureSet abstraction lets alternate randomness/time/node sources be injected, which is also how the library adapts its behavior across different PHP runtime capabilities.

Code Quality - With 114 source files organized into narrowly scoped namespaces (Builder, Codec, Converter, Generator, Validator, Provider), responsibilities are cleanly separated by concern rather than by UUID version alone. The project enforces strict tooling in CI — PHPStan (including dedicated Mockery and PHPUnit extensions), phpcs via captainhook git hooks, and phpbench for performance benchmarking — reflecting a mature, quality-gated release process for a library used as a foundational dependency across the PHP ecosystem.

API Design - The primary entry points (Uuid::uuid4(), Uuid::uuid7(), Uuid::fromString()) are short, version-specific static factory methods that map directly onto RFC 4122’s version numbers, making the common case a one-line call. The DeprecatedUuidMethodsTrait and DeprecatedUuidInterface show a deliberate, documented migration path as the API has evolved, minimizing breakage for long-time consumers while still improving the interface over time.

Used by 6 apps in this directory

PHP
63%
Other

BillaBear

Ecommerce · Invoicing Finance

754

Self-hostable subscription management and billing platform with Stripe integration, tax automation, configurable workflows, and Twig-based document generation.

View details
47
Repo Health
66
Technical
66
Dependency
Built with
PHP63%
Vue18%
Gherkin13%
Updated 2 months ago
PHP
91%
AGPL 3.0

FreeScout

Customer Support

4,484

Run your own help desk and shared inbox — a fully self-hosted, open-source alternative to Zendesk and Help Scout with no per-agent fees.

View details
93
Repo Health
55
Technical
63
Dependency
Built with
PHP91%
Updated yesterday
PHP
48%
AGPL 3.0

Leantime

Productivity · Project Management · Collaboration

11,391

Project management built for ADHD, autism, and dyslexia — simple as Trello, powerful as Jira

View details
90
Repo Health
68
Technical
67
Dependency
Built with
PHP48%
CSS20%
Blade17%
Updated 4 days ago
PHP
82%
Other

Mautic

Automation · Marketing · Ecommerce

10,366

The world's largest open source marketing automation platform — own your data, run multi-channel campaigns, and escape vendor lock-in forever.

View details
98
Repo Health
76
Technical
64
Dependency
Built with
PHP82%
Updated yesterday
PHP
100%
AGPL 3.0

Passbolt API

Password Manager · Security

6,080

Self-hosted, end-to-end encrypted password manager API built for teams who demand full ownership of their credentials.

View details
92
Repo Health
80
Technical
73
Dependency
Built with
PHP100%
Updated yesterday
PHP
99%
MIT

Shlink

Developer Tools · Marketing

5,223

Self-hosted PHP URL shortener with a full REST API, dynamic redirect rules, and real-time visit analytics under your own domain.

View details
86
Repo Health
83
Technical
72
Dependency
Built with
PHP99%
Updated 1 weeks ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search