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

小优化 #323

Open
chenpinzhong opened this issue Jul 15, 2022 · 3 comments
Open

小优化 #323

chenpinzhong opened this issue Jul 15, 2022 · 3 comments

Comments

@chenpinzhong
Copy link

chenpinzhong commented Jul 15, 2022

vendor\workerman\webman-framework\src\App.php:486
loadController 这个函数
if (\is_dir($file) || false === \strpos(strtolower($file), '/controller/') || $spl_file->getExtension() !== 'php') {
continue;
}

改为
if (\is_dir($file) || false === \strpos(strtolower($file), DIRECTORY_SEPARATOR.'controller'.DIRECTORY_SEPARATOR) || $spl_file->getExtension() !== 'php') {
continue;
}
对window 会好一些
http://127.0.0.1:19730/admin/menu.index/index 比如更深的控制器
class Server extends App{
balabalabala......
protected static function parse_controller_action($path){
$suffix = config('app.controller_suffix', '');
$path_explode = explode('/', trim($path, '/'));
$app = !empty($path_explode[0]) ? $path_explode[0] : 'index';
$controller = $path_explode[1] ?? 'index';
$controller=str_replace('.','\',$controller);// 我这边支持多层控制器的方法
$action = $path_explode[2] ?? 'index';
if (isset($path_explode[2])) {
$controller_class = "app\$app\controller\$controller$suffix";
if ($controller_action = static::get_controller_action($controller_class, $action)) {
return $controller_action;
}
}

@chenpinzhong
Copy link
Author

chenpinzhong commented Jul 15, 2022

$controller=str_replace('.','\',$controller); // \是 重复2次的 github的显示问题了
这个是我这边 想支持 更复杂的控制器结构

walkor added a commit to walkor/webman-framework that referenced this issue Jul 15, 2022
@walkor
Copy link
Owner

walkor commented Jul 15, 2022

感谢反馈。
windows优化接受了,不过以点来分割控制器感觉不规范,这个没办法支持

@chenpinzhong
Copy link
Author

嗯 以点来分割控制器 这个不重要 需要的人 可以自己实现 感谢

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