tp6.0的多应用模式
操作步骤:
1. 安装多应用模式扩展
composer require topthink/think-multi-app
2. 快速生成多应用的命令
php think build api
3. 在public目录下创建api.php入口文件
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2019 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
// [ 应用入口文件 ]
namespace think;
require __DIR__ . '/../vendor/autoload.php';
// 执行HTTP应用并响应
$http = (new App())->http;
$response = $http->name('api')->run();
$response->send();
$http->end($response);
4. 访问路由:http://本地地址/api.php