makeController($request->controller); } catch (RuntimeException $e) { throw new RRException($e->getMessage(), 404); } $action = $request->actionName; if (is_callable([$instance, $action])) { $instance->$action(); } else { // 操作不存在 throw new RRException('method not exists:'.get_class($instance) . '->' . $action . '()', 404); } } public function makeController(string $controller, bool $newInstance = false) { $class = 'app' . '\\' . 'controller' . '\\' . $controller; if (class_exists($class)) { if (isset($this->classMap[$class]) && !$newInstance) { return $this->classMap[$class]; } $instance = new $class; if (!$newInstance) { $this->classMap[$class] = $instance; } return $instance; } else { throw new RuntimeException('class not exists:' . $class); } } }