{"id":35190529,"url":"https://github.com/phrenotype/munix","last_synced_at":"2026-05-22T05:33:51.978Z","repository":{"id":58199608,"uuid":"530553776","full_name":"phrenotype/munix","owner":"phrenotype","description":"A unique id (64-bit integer) generator for php","archived":false,"fork":false,"pushed_at":"2023-09-28T01:30:44.000Z","size":10,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-30T02:49:24.002Z","etag":null,"topics":["php","php-unique-id","snowflake","unique-id"],"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/phrenotype.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2022-08-30T07:54:48.000Z","updated_at":"2022-12-21T17:40:47.000Z","dependencies_parsed_at":"2023-01-30T02:05:11.753Z","dependency_job_id":null,"html_url":"https://github.com/phrenotype/munix","commit_stats":{"total_commits":8,"total_committers":1,"mean_commits":8.0,"dds":0.0,"last_synced_commit":"c107dd3f0240bedded7e073d8c1f41b895a70a6d"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/phrenotype/munix","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phrenotype%2Fmunix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phrenotype%2Fmunix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phrenotype%2Fmunix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phrenotype%2Fmunix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phrenotype","download_url":"https://codeload.github.com/phrenotype/munix/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phrenotype%2Fmunix/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28111199,"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","status":"online","status_checked_at":"2025-12-29T02:00:07.021Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["php","php-unique-id","snowflake","unique-id"],"created_at":"2025-12-29T05:38:51.987Z","updated_at":"2025-12-29T05:38:54.009Z","avatar_url":"https://github.com/phrenotype.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Munix : A Unique ID Generator\r\n\r\nA unique random id generator that produces unique signed 64 bit integers without the need for a dedicated id server. The generated id's can be used as unique identifiers for objects. Collisions are guaranteed not to occur. This was built to run on one or several machines that accept multiple requests per second.\r\n\r\n# Install\r\n\r\n`composer install munix/munix`\r\n\r\n# Requirements\r\nMunix requires `sqlite` to be installed and enabled in `php.ini`. A small sqlite db it used to track number sequences within milliseconds of each other to prevent collisions. Yes, it's small. It just contains one table, one column, and one row (1 x 1).\r\n\r\n# Usage\r\n\r\nTo get an id, you only need to call one method, `Munix\\Munix::nextId(int $customId)`.\r\n\r\nThe only thing needed is a custom number from 0 (inclusive) to 1023 (inclusive). For a single project, any number in that range will suffice. However, if it's a distributed system, each machine will need a different number, to avoid collisions.\r\n\r\nIf no `custom id` is supplied, the default value of `0` is used.\r\n\r\n```php\r\n\u003c?php\r\n\r\nuse Munix\\Munix;\r\n\r\n// Using a custom id of 5\r\n$id = Munix::nextId(5);\r\n\r\necho $id;\r\n```\r\n\r\nWill give an output similar to\r\n\r\n`85164824987754496`\r\n\r\nTo avoid passing the `custom id` each time you need an id, set one permanently by calling `Munix\\Munix::setCustomId(int $customId)`.\r\n\r\n```php\r\n\u003c?php\r\n\r\nMunix::setCustomId(2);\r\n\r\n\r\nMunix::nextId();\r\n\r\nMunix::nextId();\r\n\r\n```\r\n## TLDR;\r\nJust call the `nextId` method whenever you need a unique Id.\r\n\r\n# Epoch\r\nYou can specify an epoch, in milliseconds by calling `Munix\\Munix::setEpoch(int $timestampInMilliseconds)`.\r\nThe default epoch is `1640991600000`, Jan 1st, 2022.\r\n\r\n```php\r\n\u003c?php\r\n\r\nMunix::setEpoch(1640991600000);\r\nMunix::setCustomId(1);\r\n\r\n// Generate all you want\r\nMunix::nextId();\r\n\r\nMunix::nextId();\r\n\r\n```\r\n\r\n# Dissection\r\n\r\nTo dissect any id generated by munix,\r\n\r\n```php\r\n\u003c?php\r\n\r\n$id = Munix::nextId();\r\n\r\n$object = new MunixId($id);\r\n\r\nvar_dump($object)\r\n\r\n```\r\n\r\nOr Even better\r\n\r\n```php\r\n\u003c?php\r\n\r\n$object = Munix::nextIdAsObject();\r\n\r\nvar_dump($object)\r\n```\r\n\r\n**The epoch should only be set once at the beginning of a project.**\r\n\r\n# Contact\r\nTwitter: @phrenotyper\r\n\r\nEmail: dev@paulrobert.xyz\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphrenotype%2Fmunix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphrenotype%2Fmunix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphrenotype%2Fmunix/lists"}