# adminmatrixServer **Repository Path**: tlan_turing/adminmatrix-server ## Basic Information - **Project Name**: adminmatrixServer - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 2 - **Created**: 2025-03-26 - **Last Updated**: 2025-03-26 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README

adminmatrix 快捷建站

# 说明 AdminMatrix 是一个基于 ThinkPHP 框架的快速建站工具,提供了完整的后台管理系统解决方案。 # 版本更新 ### 2025年3月12日10:16:55 - 创建dev分支 - 优化数据迁移功能 - 完善多应用支持 # 功能特性 - 多应用模式支持 - 注解路由 - 数据库迁移 - 控制器基类 - 中间件支持 # 安装 ```bash composer require adminmatrix/admin-server ``` # 文档 ## 多应用模式 ### 自动生成应用目录 - 多应用模式在根目录 `/app/` 中自动创建 - 基于 think build 基础开发 ### 命令行创建应用 ```bash php think build admin ``` 如果看到: > 应用【admin】安装完成 则表示自动生成应用成功。 ### 应用目录结构 会自动生成admin应用,包含以下目录和文件: - `controller/` - 控制器目录 - `model/` - 模型目录 - `view/` - 视图目录 - `common.php` - 公共函数 - `middleware.php` - 中间件配置 - `event.php` - 事件配置 - `provider.php` - 服务提供者 ### 自定义应用结构 在app目录下创建 `build.php` 文件: ```php return [ // 需要自动创建的文件 '__file__' => [], // 需要自动创建的目录 '__dir__' => ['controller', 'model', 'view'], // 需要自动创建的控制器 'controller' => ['Index'], // 需要自动创建的模型 'model' => ['User'], // 需要自动创建的模板 'view' => ['index/index'], ]; ``` ## 数据迁移 数据迁移功能提供了版本控制数据库的方式,使数据库结构修改可追踪、可回滚。 ### 迁移命令 1. **创建迁移** ```bash # 在根目录创建迁移 php think migrate:create UserTable # 在指定应用中创建迁移 php think migrate:create admin@UserTable ``` 2. **执行迁移** ```bash # 执行所有未完成的迁移 php think migrate # 执行指定应用的迁移 php think migrate --app admin ``` 3. **回滚迁移** ```bash # 回滚最后一次迁移 php think migrate:rollback # 回滚指定应用的迁移 php think migrate:rollback --app admin # 回滚指定步数 php think migrate:rollback --step 2 ``` 4. **查看迁移状态** ```bash # 查看所有迁移状态 php think migrate:status # 查看指定应用的迁移状态 php think migrate:status --app admin ``` ### 迁移文件示例 ```php createTable('users', function($table) { $table->increments('id'); $table->string('username', 100)->comment('用户名'); $table->string('password', 255)->comment('密码'); $table->string('email', 100)->unique()->comment('邮箱'); $table->tinyInteger('status')->default(1)->comment('状态'); $table->timestamps(); // 添加索引 $table->index('username'); $table->index('email'); }); } public function down(): void { $this->dropTable('users'); } } ``` ## 控制器使用 ### 基础控制器 1. 在应用目录下创建基础控制器: ```php