think-swoole icon indicating copy to clipboard operation
think-swoole copied to clipboard

请教下tp8多应用模式下 think-swoole php think swoole 子应用下 路由无效怎么解决

Open pasawu opened this issue 11 months ago • 2 comments

请教下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无效

pasawu avatar Mar 02 '24 15:03 pasawu

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; } }); 试试这样

1207702931 avatar Mar 06 '24 07:03 1207702931

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; } }); 试试这样

请问下是在什么文件加这段代码,谢谢

pasawu avatar Mar 06 '24 09:03 pasawu