dsxwk / hyperf-helper
Hyperf Framework Assistant
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/dsxwk/hyperf-helper
Requires
- php: >=8.2
- hyperf/validation: ^2.1
Requires (Dev)
- phpunit/phpunit: ^10.5
This package is not auto-updated.
Last update: 2025-10-01 02:17:41 UTC
README
安装
composer require dwxwk/hyperf-helper
验证器增强, 无需控制器引入自动识别当前请求方法,无需引入验证场景通过当前请求方法自动识别
验证器
<?php declare(strict_types=1); namespace App\Request; use Dsxwk\Framework\HyperfHelper\Request\BaseFormRequest; class IndexRequest extends BaseFormRequest { /** * 验证场景规则 * * @return array */ public function sceneRules(): array { return [ // 创建 'create' => [ 'remark' => 'nullable|string', 'attachments' => 'array', // ... ], // 更新 'update' => [ 'id' => 'required|integer|gt:0', 'remark' => 'nullable|string', 'attachments' => 'array', // ... ], ]; } /** * 提示字段设置 * * @return string[] */ public function attributes(): array { return [ 'id' => 'ID', 'remark' => '备注', 'attachments' => '附件', ]; } }
控制器
<?php declare(strict_types=1); namespace App\Controller; class IndexController { public function create() { // ... } public function update() { // ... } }