Hyperf
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 开发".From its SKILL.md
npx -y skills add fanqingxuan/awesome-skills --skill hyperfAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- runs commandsInstructs the agent to run 6 commands, including `php bin/hyperf.php gen:controller UserController` and 5 more.
SKILL.md
2.7 KB, 639 tokens by cl100k_base, as published. Nobody here has run it
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/ 目录下的官方文档:
What ships with it: 128 files
2442.4 KB alongside SKILL.md
references/
- zh-cn/amqp.md15.3 KB
- zh-cn/annotation.md11.6 KB
- zh-cn/aop.md6.9 KB
- zh-cn/async-queue.md15.5 KB
- zh-cn/awesome-components.md12.0 KB
- zh-cn/cache.md7.9 KB
- zh-cn/changelog/1.0.md21.5 KB
- zh-cn/changelog/1.1.md46.6 KB
- zh-cn/changelog/2.0.md42.9 KB
- zh-cn/changelog/2.1.md22.8 KB
- zh-cn/changelog/2.2.md19.9 KB
- zh-cn/changelog/3.0.md40.0 KB
- zh-cn/changelog/3.1.md54.8 KB
- zh-cn/circuit-breaker.md2.7 KB
- zh-cn/command.md12.3 KB
- zh-cn/communication.md904 B
- zh-cn/component-guide/configprovider.md6.0 KB
- zh-cn/component-guide/create.md913 B
- zh-cn/component-guide/intro.md4.4 KB
- zh-cn/config-center.md10.1 KB
- zh-cn/config.md11.2 KB
- zh-cn/constants.md3.8 KB
- zh-cn/consul.md3.8 KB
- zh-cn/contribute.md2.1 KB
- zh-cn/controller.md2.6 KB
- zh-cn/coroutine.md20.9 KB
- zh-cn/coroutine-server.md2.0 KB
- zh-cn/crontab.md10.2 KB
- zh-cn/dag.md10.7 KB
- zh-cn/db/db.md4.2 KB
- zh-cn/db/event.md7.3 KB
- zh-cn/db/gen.md8.6 KB
- zh-cn/db/migration.md18.7 KB
- zh-cn/db/model-cache.md8.1 KB
- zh-cn/db/model.md17.6 KB
- zh-cn/db/mutators.md14.2 KB
- zh-cn/db/paginator.md1.4 KB
- zh-cn/db/querybuilder.md20.6 KB
- zh-cn/db/quick-start.md14.5 KB
- zh-cn/db/relationship.md13.7 KB
88 more files not listed here. See all 128 in the repository.