pathinfo(); $pathinfo_array = explode('/', $pathinfo); $url = request()->domain(); $check_model = $pathinfo_array[0]; //检测当前插件情况 $addon = in_array($check_model, $system_array) ? '' : $check_model; if (!empty($addon)) { $module = isset($pathinfo_array[1]) ? $pathinfo_array[1] : 'admin'; $controller = isset($pathinfo_array[2]) ? $pathinfo_array[2] : 'index'; $method = isset($pathinfo_array[3]) ? $pathinfo_array[3] : 'index'; request()->addon($addon); $this->app->setNamespace("addon\\" . $addon . '\\' . $module); $this->app->setAppPath($this->app->getRootPath() . 'addon' . DIRECTORY_SEPARATOR . $addon . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR); } else { $module = isset($pathinfo_array[0]) ? $pathinfo_array[0] : 'admin'; $controller = isset($pathinfo_array[1]) ? $pathinfo_array[1] : 'index'; $method = isset($pathinfo_array[2]) ? $pathinfo_array[2] : 'index'; $this->app->setNamespace("app\\" . $module); $this->app->setAppPath($this->app->getRootPath() . 'app' . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR); } //解析路由 $pathinfo = str_replace(".html", '', $pathinfo); $controller = str_replace(".html", '', $controller); $method = str_replace(".html", '', $method); request()->module($module); Route::rule($pathinfo, $module . '/' . $controller . '/' . $method); } }