{"id":16674811,"url":"https://github.com/odan/tsid","last_synced_at":"2025-03-21T18:31:25.237Z","repository":{"id":64489360,"uuid":"576070958","full_name":"odan/tsid","owner":"odan","description":"A PHP library for generating Time Sortable Identifiers (TSID).","archived":false,"fork":false,"pushed_at":"2023-12-06T11:43:22.000Z","size":20,"stargazers_count":20,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-18T03:35:51.175Z","etag":null,"topics":[],"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/odan.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-09T00:06:23.000Z","updated_at":"2024-12-10T23:16:31.000Z","dependencies_parsed_at":"2024-10-28T11:28:16.730Z","dependency_job_id":"5a03e74a-46a1-46be-9ded-41633d640a86","html_url":"https://github.com/odan/tsid","commit_stats":{"total_commits":9,"total_committers":2,"mean_commits":4.5,"dds":0.2222222222222222,"last_synced_commit":"8df79d01e7ceaa8572108c6e3662516a9094a8b9"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/odan%2Ftsid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/odan%2Ftsid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/odan%2Ftsid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/odan%2Ftsid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/odan","download_url":"https://codeload.github.com/odan/tsid/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244848528,"owners_count":20520538,"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":[],"created_at":"2024-10-12T12:44:27.912Z","updated_at":"2025-03-21T18:31:24.944Z","avatar_url":"https://github.com/odan.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TSID – Time-Sorted Unique Identifiers\n\n[![Latest Version on Packagist](https://img.shields.io/github/release/odan/tsid.svg)](https://packagist.org/packages/odan/tsid)\n[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE)\n[![Build Status](https://github.com/odan/tsid/workflows/build/badge.svg)](https://github.com/odan/tsid/actions)\n[![Coverage Status](https://img.shields.io/scrutinizer/coverage/g/odan/tsid.svg)](https://scrutinizer-ci.com/g/odan/tsid/code-structure)\n[![Quality Score](https://img.shields.io/scrutinizer/quality/g/odan/tsid.svg)](https://scrutinizer-ci.com/g/odan/tsid/?branch=master)\n[![Total Downloads](https://img.shields.io/packagist/dt/odan/tsid.svg)](https://packagist.org/packages/odan/tsid/stats)\n\n## Description\n\nA library for generating Time Sortable Identifiers (TSID).\n\nThis library is a port of [TSID Creator](https://github.com/f4b6a3/tsid-creator) from Java to PHP.\n\n## Requirements\n\n * PHP 8.0+\n\n## Installation\n\n```\ncomposer require odan/tsid\n```\n\n## Usage\n\n```php\nuse Odan\\Tsid\\TsidFactory;\n\n$tsidFactory = new TsidFactory();\n\n$tsid = $tsidFactory-\u003egenerate();\n\n// 388400145978465528\necho $tsid-\u003etoInt();\n\n// 0ARYZVZXW377R\necho $tsid-\u003etoString();\n```\n\n## Database Usage\n\n### MySQL\n\nUse `bigint(20) unsigned` as datatype for the (primary / secondary) key. \n\nExample:\n\n```sql\nCREATE TABLE `users` (\n    `id` bigint(20) unsigned NOT NULL,\n    `username` varchar(45) NOT NULL,\n     PRIMARY KEY (`id`)\n) ENGINE=InnoDB\n```\n\n**Note:** When you use `BIGINT(20)` the maximum value is 2^63 - 1 == `9223372036854775807`.\nThis means there is still enough space to store any TSID.\nWhen you use `BIGINT(20) unsigned` the maximum value is: 2^64-1 = `18446744073709551615`\n\n### SQLite\n\nUse `INTEGER` as datatype for the (primary / secondary) key.\n\n```sql\nCREATE TABLE users (id INTEGER PRIMARY KEY, username TEXT);\n```\n\n**Note:** SQLite uses an 8-byte **signed** integer to store integers.\nSo the maximum positive integer value is 2^63 - 1 == `9223372036854775807`.\nThis means there is still enough space to store any TSID.\n\n## Data Type Comparison\n\n```\nTSID max:                          18446744073709551615\nTSID 2023-01-01T00:00:00.000Z:       397177100698290050\nTSID 2038-01-19T03:14:07.000Z:      2389272048961164191\nTSID 2999-12-31T23:59:59.999Z:      7015104302283010234\nPHP_INT_MAX:                        9223372036854775807\nSQLite INTEGER max:                 9223372036854775807\nMySQL BIGINT(20) max:               9223372036854775807\nMySQL BIGINT(20) unsigned max:     18446744073709551615\n```\n\n## Read more\n\n* https://vladmihalcea.com/uuid-database-primary-key/\n* https://github.com/f4b6a3/tsid-creator\n* [UUID version 7](https://symfony.com/doc/current/components/uid.html#generating-uuids) features a time-ordered value field.\n* [ULID's](https://symfony.com/doc/current/components/uid.html#ulids) are 128-bit numbers with a timestamp and random bits.\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fodan%2Ftsid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fodan%2Ftsid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fodan%2Ftsid/lists"}