{"id":18737261,"url":"https://github.com/zyprosoft/hyperf-common","last_synced_at":"2026-01-27T09:41:59.314Z","repository":{"id":57092463,"uuid":"415542938","full_name":"zyprosoft/hyperf-common","owner":"zyprosoft","description":"基于Hyperf框架进行的一些封装，方便记录Log日志，设计了ZGW协议，能够快速的实现访问频率限制和请求防篡改","archived":false,"fork":false,"pushed_at":"2025-12-12T03:16:27.000Z","size":358,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-13T08:18:49.080Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zyprosoft.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2021-10-10T09:41:49.000Z","updated_at":"2025-12-12T03:15:34.000Z","dependencies_parsed_at":"2024-10-19T08:24:04.595Z","dependency_job_id":"747ed602-b09a-4f52-b537-911b6397470a","html_url":"https://github.com/zyprosoft/hyperf-common","commit_stats":{"total_commits":164,"total_committers":2,"mean_commits":82.0,"dds":0.04268292682926833,"last_synced_commit":"72567a545d9faf1fef1fe8586f8e5957a0d78863"},"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"purl":"pkg:github/zyprosoft/hyperf-common","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zyprosoft%2Fhyperf-common","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zyprosoft%2Fhyperf-common/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zyprosoft%2Fhyperf-common/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zyprosoft%2Fhyperf-common/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zyprosoft","download_url":"https://codeload.github.com/zyprosoft/hyperf-common/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zyprosoft%2Fhyperf-common/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28811206,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-27T07:41:26.337Z","status":"ssl_error","status_checked_at":"2026-01-27T07:41:08.776Z","response_time":168,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":[],"created_at":"2024-11-07T15:24:27.999Z","updated_at":"2026-01-27T09:41:59.297Z","avatar_url":"https://github.com/zyprosoft.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"####\n内部库\n\n####一、使用zyprosoft/hyperf-skeleton项目来创建脚手架\n1. composer create-project zyprosoft/hyperf-skeleton\n2. 完成后执行composer install\n\n####ZGW协议接口开发\n三段式接口名：大模块名.控制器.方法\n使用AutoController(prefix=\"大模块名/控制器\")进行注解之后，\n按照ZGW协议请求便可自动调用到对应的方法\n如下示范:ZgwController下使用AutoController(prefix=\"/common/zgw\")进行注解之后便可\n请求到sayHello方法\n```php\ncurl -d'{\n    \"version\":\"1.0\",\n    \"seqId\":\"xxxxx\",\n    \"timestamp\":1601017327,\n    \"eventId\":1601017327,\n    \"caller\":\"test\",\n    \"interface\":{\n        \"name\":\"common.zgw.sayHello\",\n        \"param\":{}\n    }\n}' http://127.0.0.1:9506\n```\n\n####普通协议开发可直接按照想要的路径做AutoController注解即可\n\n####根据需求继承需要鉴权和不需要鉴权的Request\nAdminRequest:需要管理员身份的请求\nAuthedRequest:需要登陆身份的请求\n\n####zgw协议请求内容防篡改\n签名算法:\n在hyperf-common.php配置好appId和appSecret\n第一步:生成当前时间戳timestamp和随机字符串nonce\n第二步:取出协议中的interface.name和param, php eg. ```$name = $reqBody['interface']['name']```;\n第三步:将第一步取出的参数按照如下加入到param, php eg. ```$param['interfaceName'] = $name```;\n第四步:将第二步的param参数按照首字母升序 \n第五步:将第四部参数数组json编码后进行md5编码得到参数字符串paramString,注意这里json编码不要主动编码为Unicode,不转义/字符\n第六步:按照下面的格式拼接参数:\nappId=$appId\u0026appSecret=$appSecret\u0026nonce=$nonce\u0026timestamp=$timestamp\u0026$paramString;\n第七步:用appSecret和第六步字符串采用sha256算法算出签名\n第八步:将得到的签名使用参数名signature加入到请求协议的外层即可\n\n重点:如果是接口带文件上传，需要将上述得到的auth和interface字段进行json编码,后端会在获取到请求的时候自动解码\n\n参考请求包\n```php\ncurl -d'{\n    \"auth\":{\n       \"timestamp\":1601017327,\n       \"nonce\":\"1601017327\",\n       \"appId\":\"test\",\n       \"signature\":\"xxasdfsfdsfffg\"\n    },\n    \"version\":\"1.0\",\n    \"seqId\":\"xxxxx\",\n    \"timestamp\":1601017327,\n    \"eventId\":1601017327,\n    \"caller\":\"test\",\n    \"interface\":{\n        \"name\":\"common.zgw.sayHello\",\n        \"param\":{}\n    }\n}' http://127.0.0.1:9506\n```\n本地开发：\n\n   docker run -d --name hyperf-common \\\n   -v /Users/zyvincent/Desktop/iCodeFutureWorkSpace/hyperfCommon:/data/project \\\n   -p 8001:8001 -it \\\n   --privileged -u root \\\n   --entrypoint /bin/sh \\\n   hyperf/hyperf:8.0-alpine-v3.12-swoole","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzyprosoft%2Fhyperf-common","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzyprosoft%2Fhyperf-common","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzyprosoft%2Fhyperf-common/lists"}