ip(); // if($local_ip !== $request_id){ // return false; // } $controller = str_replace('.', '\\', $request->controller()); $controller = '\\app\\api\\controller\\' . $controller . 'Controller'; $controllerClass = invoke($controller); if (($controllerClass instanceof BaseApiController) === false) { throw new ControllerExtendException($controller, '404'); } } catch (ClassNotFoundException $e) { throw new HttpException(404, 'controller not exists:' . $e->getClass()); } //创建控制器对象 $request->controllerObject = invoke($controller); return $next($request); } }