hyperf
@fanqingxuan · 收录于 1 周前
Hyperf 3.1 framework development assistant. Use when the user needs to: (1) Create Hyperf controllers, (2) Create Hyperf models, (3) Create Hyperf commands, (4) Implement services, (5) Configure routes, (6) Use dependency injection, (7) Handle validation, or any other Hyperf 3.1 development tasks. Triggers on phrases like "创建 Hyperf 控制器", "生成模型", "创建命令", "Hyperf 开发".
适合你,如果正在用 Hyperf 3.1 开发 PHP 后端应用
/ 下载安装
用别的 agent?下载 .zip 解压,把文件夹放进它的技能目录
Claude Code
~/.claude/skills/(项目级 .claude/skills/)Codex CLI
~/.codex/skills/Cursor自动读取上面两处目录
其他工具见其文档的「skills」目录;两个下载是同一份文件,只是名字不同
/ 通过 npx 安装 校验哈希
npx oh-my-skill add fanqingxuan/awesome-skills/hyperf/ 通过 bash 安装
curl -fsSL https://oh-my-skill.com/install.sh | bash -s -- fanqingxuan/awesome-skills/hyperf/ 已经装过?验证本机副本,不用重装
npx oh-my-skill verify fanqingxuan/awesome-skills/hyperf安装目标可用 --agent / --scope 或 --to 明确指定;省略时只会在唯一已存在的 agent 目录上自动选择,零命中或多命中会停止并提示。content_hash 缺失或不一致均拒装。
25GitHub stars
~650最小装载
~26.8K含声明引用
~295.9K文本包总量
镜像托管
怎么用
技能原文 SKILL.md
Hyperf 3.1 开发指南
Hyperf 3.1 框架开发助手,专注于控制器、模型、命令行工具的快速开发。
常用命令
# 生成控制器 php bin/hyperf.php gen:controller UserController # 生成模型 php bin/hyperf.php gen:model User # 生成命令 php bin/hyperf.php gen:command ImportCommand # 生成中间件 php bin/hyperf.php gen:middleware AuthMiddleware # 生成请求验证类 php bin/hyperf.php gen:request UserRequest # 启动服务 php bin/hyperf.php start
快速示例
控制器
<?php
declare(strict_types=1);
namespace App\Controller;
use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\GetMapping;
#[Controller(prefix: "/api/users")]
class UserController extends AbstractController
{
#[GetMapping("")]
public function index()
{
return $this->response->json(['code' => 0, 'data' => []]);
}
}
模型
<?php
declare(strict_types=1);
namespace App\Model;
use Hyperf\DbConnection\Model\Model;
class User extends Model
{
protected ?string $table = 'users';
protected array $fillable = ['name', 'email'];
}
命令
<?php
declare(strict_types=1);
namespace App\Command;
use Hyperf\Command\Command as HyperfCommand;
use Hyperf\Command\Annotation\Command;
#[Command]
class ImportDataCommand extends HyperfCommand
{
protected ?string $name = 'import:data';
public function handle()
{
$this->info('Processing...');
}
}
服务类
<?php
declare(strict_types=1);
namespace App\Service;
use App\Model\User;
class UserService
{
public function create(array $data): User
{
return User::create($data);
}
}
官方文档参考
详细文档请参考 references/zh-cn/ 目录下的官方文档:
- 控制器: [references/zh-cn/controller.md](references/zh-cn/controller.md)
- 模型: [references/zh-cn/db/model.md](references/zh-cn/db/model.md)
- 命令行: [references/zh-cn/command.md](references/zh-cn/command.md)
- 路由: [references/zh-cn/router.md](references/zh-cn/router.md)
- 验证器: [references/zh-cn/validation.md](references/zh-cn/validation.md)
- 依赖注入: [references/zh-cn/di.md](references/zh-cn/di.md)
按 MIT 许可原样转载,未经改动 · 在 GitHub 查看 →
评论
登录即可评论;带「已验证安装」的,是发布者名下有本店的安装或持有记录。
…