{"id":23150866,"url":"https://github.com/hyperf-plus/helper","last_synced_at":"2026-03-11T07:02:34.517Z","repository":{"id":43269777,"uuid":"298603166","full_name":"hyperf-plus/helper","owner":"hyperf-plus","description":null,"archived":false,"fork":false,"pushed_at":"2025-10-11T04:25:25.000Z","size":63,"stargazers_count":4,"open_issues_count":0,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-12T17:22:51.732Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/hyperf-plus.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}},"created_at":"2020-09-25T14:55:56.000Z","updated_at":"2025-10-11T04:25:06.000Z","dependencies_parsed_at":"2024-08-16T06:00:05.711Z","dependency_job_id":null,"html_url":"https://github.com/hyperf-plus/helper","commit_stats":{"total_commits":9,"total_committers":2,"mean_commits":4.5,"dds":"0.11111111111111116","last_synced_commit":"7459784d6c30e7361b21407de94cc4f853647a23"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"purl":"pkg:github/hyperf-plus/helper","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperf-plus%2Fhelper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperf-plus%2Fhelper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperf-plus%2Fhelper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperf-plus%2Fhelper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hyperf-plus","download_url":"https://codeload.github.com/hyperf-plus/helper/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperf-plus%2Fhelper/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30373510,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-11T06:09:32.197Z","status":"ssl_error","status_checked_at":"2026-03-11T06:09:17.086Z","response_time":84,"last_error":"SSL_read: 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-12-17T18:18:47.127Z","updated_at":"2026-03-11T07:02:34.505Z","avatar_url":"https://github.com/hyperf-plus.png","language":"PHP","readme":"# hyperf-helper\nhyperf-helper 工具助手，自动生成service、api控制器、验证器\n安装方法\n```shell script\ncomposer require hyperf-plus/helper\n```\n#模型方法自动提示\n````\n在基类注解上 @mixin \\HyperfEloquent  即可实现自定提示，示例如下：\n/**\n * @package HPlus\\Admin\\Model\n * @mixin \\HyperfEloquent #增加此注解，即可实现 User::where()-\u003efind()、(new User)-\u003eid 等等的自动提示\n */\nabstract class Model extends BaseModel\n{\n    use Cacheable;\n}\n\n````\n#常用方法\n````\nRedis()          #获取redis实例\nLogger()         #获取日志实例\nget_client_ip()    #获取客户端ip\nget_container()   #获取DI容器\nverify_ip()       #验证IP有效性\np()              #打印调试日志到控制台\nuuid(32)         #生成不重复的字符串\nfilter_emoji（）   #filterEmoji表情过滤\nconvert_hump()    #数组驼峰key 转下划线key\nsession()        #设置Session管理\nget_session（）    #获取session实例\nsession_destroy() #销毁当前Session实例\n````\n\n### 工具1 QueryHelper\n第一步 引入 \n```php\nuse GetQueryHelper;\n```\n\n第二步使用：\n```php\n        //获得模型\n        $userModel = User::query();\n        //（1）可以再模型设置条件，join 之类的\n        $userModel-\u003ewhere('id', 1)-\u003ewhere('status', 1);\n\n        //引入QueryHelper  第一个参数传模型对象，第二个参数传 数组分页查找\n        $query = $this-\u003eQueryHelper($userModel, $data);\n\n        //如果不用（1）方法也可以在引入引入QueryHelper后再对模型进行\n        $query-\u003equery-\u003ewhere('id', 1);\n        $query-\u003equery-\u003ejoin('','','','');\n        //...等等所有模型操作\n\n        // 切入url参数，接收 username 和 keywords 并使用 like 查询，接收 user_id is_top 使用 eq 查询\n        $query-\u003eequal('user_id,is_top');\n        $query-\u003elike('username,keywords');\n        //用法1\n        $query-\u003etimeBetween('字段');\n        $query-\u003etimeBetween([\n            '开始时间字段',\n            '结束时间字段'\n        ]);\n        $query-\u003edateBetween('日期字段');\n        $query-\u003edateBetween([\n            '开始日期字段',\n            '结束日期字段'\n        ]);\n        //启用自动分页 paginate 第一个参数可选，列表返回字段，第二个参数可以传一个匿名函数 可以再里面修改返回列表集合\n        return $query-\u003epaginate();\n\n``` \n\n#工具2 自动生成工具依赖\n## gen:api\n自动生成api文件，自动把swagger注解，和常用代码给生成出来\n#### 参数1：类名\n#### 参数2：当前模块名字（swagger上展示用）\n#### 参数3：当前模块介绍（swagger上展示用）\n\n例如生成api User控制器(支持多级目录)：\n```shell script\nphp bin/hyperf.php gen:api User 用户控制器 介绍\n执行后会在 App/Controller里生成User.php 类\n\n#多级目录\nphp bin/hyperf.php gen:api Api/v1/User 用户控制器 介绍\n执行后会在 App/Controller/api/v1/下生成User.php 类\n```\n\n## gen:service\n自动生成service文件，把常用代码给生成出来\n\n```shell script\nphp bin/hyperf.php gen:service User\n执行后会在 App\\Serivce 里生成UserService.php 类\n\n```\n## gen:validate\n自动生成验证器文件，把常用规则给生成出来\n\n```shell script\nphp bin/hyperf.php gen:validate User\n执行后会在 App\\Validate 里生成UserValidation.php 类并把默认规则填入\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhyperf-plus%2Fhelper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhyperf-plus%2Fhelper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhyperf-plus%2Fhelper/lists"}