think-swoole
think-swoole copied to clipboard
请教下tp8多应用模式下 think-swoole php think swoole 子应用下 路由无效怎么解决
请教下tp8多应用模式下 think-swoole php think swoole 子应用下 路由无效怎么解决
app/ ├── api/ │ ├── route/ │ │ ├── api.php │ │ └── user.php │ └── ... ├── adminapi/ │ ├── route/ │ │ ├── api.php │ │ └── user.php │ └── ... └── route/ └── app.php
只有route下的路由有效api和adminapi下的route无效
Event::listen(RouteLoaded::class, function () { $url = app()->request->url(); $url = str_starts_with($url, '/') ? substr($url, 1) : $url; $sub_app = substr($url, 0, strpos($url, '/')); app()->route->clear(); foreach (glob(root_path() . 'app/'.$sub_app . '/route/*.php') as $item) { include $item; } }); 试试这样
Event::listen(RouteLoaded::class, function () { $url = app()->request->url(); $url = str_starts_with($url, '/') ? substr($url, 1) : $url; $sub_app = substr($url, 0, strpos($url, '/')); app()->route->clear(); foreach (glob(root_path() . 'app/'.$sub_app . '/route/*.php') as $item) { include $item; } }); 试试这样
请问下是在什么文件加这段代码,谢谢