{"id":33984560,"url":"https://github.com/pangongzi/algorithm","last_synced_at":"2026-05-27T18:04:53.499Z","repository":{"id":278098926,"uuid":"934523939","full_name":"pangongzi/algorithm","owner":"pangongzi","description":"A PHP library for implementing various algorithms","archived":false,"fork":false,"pushed_at":"2025-02-18T02:31:43.000Z","size":6,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-14T16:50:20.390Z","etag":null,"topics":["algorithm","php","snowflake"],"latest_commit_sha":null,"homepage":"https://github.com/pangongzi/algorithm","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pangongzi.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-02-18T01:23:01.000Z","updated_at":"2025-02-18T02:29:46.000Z","dependencies_parsed_at":null,"dependency_job_id":"02d2ff71-d987-42ad-9c88-57a616185a2d","html_url":"https://github.com/pangongzi/algorithm","commit_stats":null,"previous_names":["pangongzi/algorithm"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/pangongzi/algorithm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pangongzi%2Falgorithm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pangongzi%2Falgorithm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pangongzi%2Falgorithm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pangongzi%2Falgorithm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pangongzi","download_url":"https://codeload.github.com/pangongzi/algorithm/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pangongzi%2Falgorithm/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33577691,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-27T02:00:06.184Z","response_time":53,"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":["algorithm","php","snowflake"],"created_at":"2025-12-13T04:32:49.214Z","updated_at":"2026-05-27T18:04:53.494Z","avatar_url":"https://github.com/pangongzi.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Algorithm | php算法库\n\n###  项目描述\n`pangongzi/algorithm` 是一个 PHP 库，提供了多种算法的实现，包括雪花算法等。  \n目前仅有雪花算法\n\n###  安装\n\n使用 Composer 安装：\n\n```bash\n# 安装\ncomposer require pangongzi/algorithm\n\n# 更新\ncomposer update pangongzi/algorithm\n\n# 删除\ncomposer remove pangongzi/algorithm\n\n```\n\n###  使用方法\n雪花算法\n初始化 首先，需要引入自动加载文件并实例化 SnowflakeService 类：\n\n```php\n\u003c?php\nrequire 'vendor/autoload.php';\nuse Pangongzi\\Algorithm\\Snowflake\\SnowflakeService;\n$snowflake = new SnowflakeService(1); // 传入机器ID\n```\n\n### 生成唯一ID\n使用 generate 方法生成唯一ID：\n\n```php\n\u003c?php\n$id = $snowflake-\u003egenerate();\necho \"生成的唯一ID: \" . $id . PHP_EOL;\n// int(546849135915962368)\n```\n\n\n\n###  编码为 Base62 字符串\n使用 encode 方法将生成的ID编码为 Base62 字符串：\n\n```php\n\u003c?php\n$encodedId = SnowflakeService::encode($id);\necho \"Base62 编码后的ID: \" . $encodedId . PHP_EOL;\n// string(10) \"eOZdhSEnw0\"\n```\n\n\n###  贡献\n欢迎提交问题和贡献代码！请确保在提交之前阅读并遵循我们的贡献指南。\n\n\n### 交流\nemail | 邮件　pangongzi1989@gmail.com  \n\nwechat | 微信    \n[![wechat.jpg](https://i.postimg.cc/hvvW2WWw/wechat.jpg)](https://postimg.cc/S2BvKPK7)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpangongzi%2Falgorithm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpangongzi%2Falgorithm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpangongzi%2Falgorithm/lists"}