1. 程式人生 > >TP5單入口繫結多模組

TP5單入口繫結多模組

// 定義應用目錄
define('APP_PATH', __DIR__ . '/../app/');

require __DIR__ . '/../thinkphp/base.php';// 載入框架基礎檔案
//開啟域名部署後
switch ($_SERVER['HTTP_HOST']) {
    case 'www.xxxx.com':
        $model = 'home';// home模組
        $route = true;// 開啟路由
        break;
    case 'admin.xxxx.com':
        $model = 'admin';// admin模組
        $route = false;// 關閉路由
        break;
}
\think\Route::bind($model ?? 'home');// 綁定當前入口檔案到模組
\think\App::route($route ?? true);// 路由
\think\App::run()->send();// 執行應用