ydg / hyperf-admin-generator
Hyperf 管理代码生成器
v3.1.0
2024-08-27 02:57 UTC
Requires
- php: >=8.1
- hyperf/database: ^3.1
- hyperf/support: ^3.1
Requires (Dev)
Suggests
- ext-json: Required to use JSON.
- ext-openssl: Required to use HTTPS.
- ext-pdo: Required to use MySQL Client.
- ext-pdo_mysql: Required to use MySQL Client.
- ext-redis: Required to use Redis Client.
This package is auto-updated.
Last update: 2024-09-27 10:20:14 UTC
README
📦 Hyperf 管理代码生成器
安装
composer require ydg/hyperf-admin-generator
使用方法
生成控制器
<?php use HyperfAdminGenerator\ControllerGenerator; (new ControllerGenerator('your module', 'your table name'))->generator();
带有更多注解的生成控制器
<?php use HyperfAdminGenerator\ControllerGenerator; (new ControllerGenerator('your module', 'your table name', 'your annotation class'))->generator();
示例
<?php use HyperfAdminGenerator\ControllerGenerator; use App\Annotation\Auth; $moduleName = 'System'; $tableName = 'system_user'; (new ControllerGenerator($moduleName, $tableName, Auth:class))->generator();
生成请求
<?php use HyperfAdminGenerator\MapperGenerator; (new RequestGenerator('your module', 'your table name'))->generator();
带有列的生成请求
<?php use HyperfAdminGenerator\MapperGenerator; (new RequestGenerator('your module', 'your table name', 'your table columns'))->generator();
在 Hyperf 中的示例
<?php use HyperfAdminGenerator\MapperGenerator; use Hyperf\Database\ConnectionResolverInterface; $moduleName = 'System'; $tableName = 'system_user'; $resolver = container()->get(ConnectionResolverInterface::class); $columns = $resolver->connection()->getSchemaBuilder()->getColumnTypeListing($tableName); (new RequestGenerator($moduleName, $tableName, $columns))->generator();
生成服务
<?php use HyperfAdminGenerator\ServiceGenerator; (new ServiceGenerator('your module', 'your table name'))->generator();
生成映射器
<?php use HyperfAdminGenerator\MapperGenerator; (new MapperGenerator('your module', 'your table name'))->generator();