Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
pasawu opened this issue Mar 2, 2024 · 2 comments

Comments

@pasawu
Copy link

pasawu commented Mar 2, 2024

请教下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 pasawu changed the title 请教tp8多应用模式下 think-swoole php think swoole 子应用下 路由无效怎么解决 请教下tp8多应用模式下 think-swoole php think swoole 子应用下 路由无效怎么解决 Mar 2, 2024
@1207702931
Copy link

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
Copy link
Author

pasawu commented Mar 6, 2024

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants