{"id":15029761,"url":"https://github.com/ramsey/identifier","last_synced_at":"2025-08-08T17:09:04.202Z","repository":{"id":59042329,"uuid":"535140145","full_name":"ramsey/identifier","owner":"ramsey","description":"A PHP library for generating and working with identifiers, including UUIDs, ULIDs, and Snowflakes","archived":false,"fork":false,"pushed_at":"2025-06-10T03:25:57.000Z","size":830,"stargazers_count":46,"open_issues_count":0,"forks_count":5,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-06-10T04:21:46.770Z","etag":null,"topics":["guid","id","identifier","php","snowflake","uid","ulid","uuid"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ramsey.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"ramsey"}},"created_at":"2022-09-10T23:07:47.000Z","updated_at":"2025-06-10T03:26:00.000Z","dependencies_parsed_at":"2025-02-15T21:32:14.848Z","dependency_job_id":"617aa999-30bd-425e-ac60-98266120b2e4","html_url":"https://github.com/ramsey/identifier","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ramsey/identifier","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ramsey%2Fidentifier","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ramsey%2Fidentifier/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ramsey%2Fidentifier/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ramsey%2Fidentifier/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ramsey","download_url":"https://codeload.github.com/ramsey/identifier/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ramsey%2Fidentifier/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259377082,"owners_count":22848285,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["guid","id","identifier","php","snowflake","uid","ulid","uuid"],"created_at":"2024-09-24T20:11:35.155Z","updated_at":"2025-08-08T17:09:04.189Z","avatar_url":"https://github.com/ramsey.png","language":"PHP","funding_links":["https://github.com/sponsors/ramsey"],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003eramsey/identifier\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003cstrong\u003eA PHP library for generating and working with identifiers\u003c/strong\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://github.com/ramsey/identifier\"\u003e\u003cimg src=\"https://img.shields.io/badge/source-ramsey/identifier-blue.svg?style=flat-square\" alt=\"Source Code\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://packagist.org/packages/ramsey/identifier\"\u003e\u003cimg src=\"https://img.shields.io/packagist/v/ramsey/identifier.svg?style=flat-square\u0026label=release\" alt=\"Download Package\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://php.net\"\u003e\u003cimg src=\"https://img.shields.io/packagist/dependency-v/ramsey/identifier/php-64bit?style=flat-square\u0026colorB=%238892BF\" alt=\"PHP Programming Language\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/ramsey/identifier/blob/main/COPYING.LESSER\"\u003e\u003cimg src=\"https://img.shields.io/packagist/l/ramsey/identifier?style=flat-square\u0026colorB=darkcyan\" alt=\"Read License\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/ramsey/identifier/actions/workflows/continuous-integration.yml\"\u003e\u003cimg src=\"https://img.shields.io/github/actions/workflow/status/ramsey/identifier/continuous-integration.yml?branch=main\u0026style=flat-square\u0026logo=github\" alt=\"Build Status\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://codecov.io/gh/ramsey/identifier\"\u003e\u003cimg src=\"https://img.shields.io/codecov/c/gh/ramsey/identifier?label=codecov\u0026logo=codecov\u0026style=flat-square\" alt=\"Codecov Code Coverage\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## About\n\nramsey/identifier is a PHP library designed for generating, parsing, and working with a variety of unique identifiers.\nIt provides an object-oriented interface for several industry-standard identifier formats—including UUIDs, ULIDs, and\nSnowflake IDs. This library emphasizes standards-compliance, interoperability, and developer ergonomics, making it easy\nto create and manipulate identifiers in modern PHP applications.\n\nThis project adheres to a [code of conduct](CODE_OF_CONDUCT.md). By participating in this project and its community, you\nare expected to uphold this code.\n\n## Installation\n\nInstall this package as a dependency using [Composer](https://getcomposer.org).\n\n``` bash\ncomposer require ramsey/identifier\n```\n\n## Usage\n\nramsey/identifier provides ways to generate industry-standard identifiers, such as UUIDs, ULIDs, and Snowflake IDs. You\ncan do this using the provided factory classes:\n\n```php\nuse Ramsey\\Identifier\\Snowflake\\GenericSnowflakeFactory;\nuse Ramsey\\Identifier\\Snowflake\\Epoch;\nuse Ramsey\\Identifier\\Ulid\\UlidFactory;\nuse Ramsey\\Identifier\\Uuid\\UuidFactory;\n\n// Create a UUID.\n$uuid = (new UuidFactory())-\u003ecreate();\n\n// Create a ULID.\n$ulid = (new UlidFactory())-\u003ecreate();\n\n// Create a Snowflake.\n$snowflake = (new GenericSnowflakeFactory(1, Epoch::Unix))-\u003ecreate();\n```\n\nWith `UuidFactory`, you may create UUIDs of different versions:\n\n```php\nuse Ramsey\\Identifier\\Uuid\\NamespaceId;\n\n$factory = new UuidFactory();\n\n// Create random UUIDs (version 4).\n$uuidV4 = $factory-\u003ev4();\n\n// Create named-based UUIDs using SHA-1 hashing (version 5).\n$uuidV5 = $factory-\u003ev5(NamespaceId::Url, 'https://example.com/post/1234');\n\n// Create Unix Epoch time-based UUIDs (version 7).\n$uuidV7 = $factory-\u003ev7();\n```\n\nYou may also parse existing identifiers:\n\n```php\n// Parse a UUID.\n$uuid = (new UuidFactory())-\u003ecreateFromString('01977bea-d1c0-7154-87bb-6550974155c2');\n\n// Parse a ULID.\n$ulid = (new UlidFactory())-\u003ecreateFromString('01JXXYNME0E5A8FEV5A2BM2NE2');\n\n// Parse a Snowflake ID.\n$snowflake = (new GenericSnowflakeFactory(1, Epoch::Unix))-\u003ecreateFromInteger(7340580095540599922);\n```\n\nEach of these identifiers happen to contain the same timestamp, which we can retrieve:\n\n```php\necho $uuid-\u003egetDateTime()-\u003eformat('Y-m-d H:i:s.v P') . \"\\n\";\necho $ulid-\u003egetDateTime()-\u003eformat('Y-m-d H:i:s.v P') . \"\\n\";\necho $snowflake-\u003egetDateTime()-\u003eformat('Y-m-d H:i:s.v P') . \"\\n\";\n```\n\nThis will print:\n\n```\n2025-06-17 03:24:36.160 +00:00\n2025-06-17 03:24:36.160 +00:00\n2025-06-17 03:24:36.160 +00:00\n```\n\nThe UUID and ULID shown above have the same underlying byte values. Every version 7 UUID can also be expressed as a\nULID, but not every ULID can be converted into a version 7 UUID. Similarly, Snowflake identifiers and ULIDs both encode\na timestamp and randomness, but their formats are not directly interchangeable with UUIDs or each other.\n\n```php\nif ($uuid-\u003eequals($ulid)) {\n    echo \"They are equal!\\n\";\n}\n\nif ($uuid-\u003eequals($snowflake)) {\n    echo \"The timestamp is the same, but they aren't equal.\\n\"\n}\n```\n\n## Contributing\n\nContributions are welcome! To contribute, please familiarize yourself with [CONTRIBUTING.md](CONTRIBUTING.md).\n\n## Coordinated Disclosure\n\nKeeping user information safe and secure is a top priority, and we welcome the contribution of external security\nresearchers. If you believe you've found a security issue in software that is maintained in this repository, please read\n[SECURITY.md](SECURITY.md) for instructions on submitting a vulnerability report.\n\n## Copyright and License\n\nramsey/identifier is copyright © [Ben Ramsey](https://ramsey.dev) and [Contributors](https://github.com/ramsey/identifier/graphs/contributors)\nand licensed for use under the terms of the GNU Lesser General Public License (LGPL-3.0-or-later) as published by the\nFree Software Foundation. Please see [COPYING.LESSER](COPYING.LESSER), [COPYING](COPYING), and [NOTICE](NOTICE) for more\ninformation.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Framsey%2Fidentifier","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Framsey%2Fidentifier","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Framsey%2Fidentifier/lists"}