garfield247/agent-skill-hyperf-framework/hyperf-framework
Claude Code and agent skill by garfield247/agent-skill-hyperf-framework
Trust tier 2
- community
Source check pending
Checking that the SKILL.md file is still in the repository.
PHP 8.1+ 与 Hyperf 3.1 协程微服务架构通用开发与工程规范技能。 涵盖 Controller->DTO->Service->Repository 四层分层架构标准、Swoole 协程常驻内存安全红线 (Hyperf\Context\Context)、 PHP 8 Attribute 原生注解规范、HTTP 路由与参数约定 (禁 URL Path 业务参数)、 数据库事务边界与 N+1 查询杜绝、异步队列幂等与多实例 Crontab 分布式锁防护。
Install
npx vskill@latest install garfield247/agent-skill-hyperf-framework/hyperf-frameworkSKILL.md
The same SKILL.md was published earlier as garfield247/agent-skill-hyperf-framework/hyperf-framework.
PHP 8.1+ & Hyperf 3.1 协程微服务开发规范 (Hyperf Framework Mastery)
本技能定义了基于 PHP 8.1+ 与 Hyperf 3.1 (Swoole 协程常驻内存) 构建高性能后端微服务时的架构分层准则、协程状态安全门禁与渐进式手册索引。
1. 核心铁律与绝对红线 (Core Redlines)
- 🚨 四层单向依赖架构:
- 严格遵循
Controller -> DTO -> Service -> Repository; - Controller 严禁包含 SQL/Redis 代码;Service 严禁泄漏 HTTP Request 对象;DTO 严禁网络/存储 I/O。
- 🚨 Swoole 协程常驻内存安全黄金红线:
- 绝对禁止在单例属性(`$this->xxx`)或静态属性中保存请求级用户状态;
- 必须通过
Hyperf\Context\Context进行协程上下文隔离;全面禁用$_GET、$_SESSION全局变量。
- 🚨 子协程崩溃拦截门禁:
- 使用
Coroutine::create派生子协程时,代码体内必须 100% 自包含 `try-catch (\Throwable $e)`,严禁未捕获异常击垮底层 Swoole Worker 进程。
- 🚨 杜绝 N+1 循环查询与路由参数约定:
- 严禁在循环体内执行 SQL 查询或 Redis 单条读取,统一批量获取后在内存通过关联键对齐;
- 严禁使用 URL Path 传递业务字段(如
/device/{id}),读接口统一使用 Query,写接口统一使用 JSON Body。
- 🚨 队列幂等与 Crontab 分布式锁:
- 异步队列消费者必须具备业务唯一键幂等校验与重试上限;
- 多 Pod 集群环境下,Crontab 定时任务必须通过 Redis 分布式互斥锁防并发重复执行。
2. 标准开发工作流 (Standard Workflow)
- 路由与 DTO:在 Controller 声明 PHP 8 Attribute 注解并绑定强类型 DTO 校验入参;
- 用例编排:Service 层编排业务逻辑,通过
Db::transaction控制事务边界; - 数据隔离:涉及请求上下文统一存取自
Context,持久化交互收敛于 Repository; - 批量收敛:列表或关联数据统一走批量查询与内存索引映射;
- 异步防护:子协程增加全量拦截,Crontab 增加 Redis 分布式防重锁。
3. 渐进式专业参考手册 (Progressive Disclosure References)
根据具体涉及的业务场景,按需查阅 `references/` 目录下的专门规约,严禁将全量子文档一次性无脑全部展开:
| 场景模块 | 参考子文档 | 核心涵盖规范 | |
|---|---|---|---|
| 四层分层与路由规范 | 01_four_layer_architecture_and_routes.md | • Controller/DTO/Service/Repository 职责与红线<br>• PHP 8 Attribute 注解与禁止 URL Path 传参约定 | |
| 协程状态安全与上下文 | 02_coroutine_state_safety_and_context.md | • 单例属性跨协程串染机理与 Context 隔离正反例<br>• 派生子协程 100% 崩溃拦截与 Worker 保护 | |
| 查询优化与事务控制 | 03_query_optimization_and_transactions.md | • 杜绝循环内 N+1 查询批量化与内存键对齐<br>• data_get 安全访问与海量数据 chunkById 事务拆解 | |
| 队列幂等与 Crontab 锁 | 04_async_queue_and_crontab_lock.md | • 异步消息至少一次投递与消费端幂等防重<br>• 多 Pod 容器集群 Crontab Redis 分布式互斥锁 |
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/hyperf-framework/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/garfield247/agent-skill-hyperf-framework/hyperf-framework)