安装thinkphp6
cd D:\www
composer create-project topthink/think tp6-admin-api # 项目名称
多应用模式
安装多应用模式扩展think-multi-app
cd D:\www\tp6-admin-api # 进入项目目录
composer require topthink/think-multi-app
创建admin应用
php think build admin
为应用添加路由
复制根目录下route文件夹到admin应用目录中,修改route目录中的app.php
添加路由规则
#app\admin\route\app.php
<?php
use think\facade\Route;
#/admin/v1/index/(index/add/edit...) 对应 /app/admin/controller/v1/index.php
Route::rule(':version/:controller/:action', 'admin/:version.:controller/:action');
#/admin/v1/index 对应 /app/admin/controller/v1/index.php
Route::rule(':version/:controller', 'admin/:version.:controller/index');
遇到问题
执行composer安装thinkphp6时报错:
[InvalidArgumentException]Could not find package topthink/think with stability stable.
删除之前的镜像:composer config -g --unset repos.packagist
再重新安装即可