IndexController.php namespace App\Http\Controller; /** * */ class IndexController { public function dd() { $name = '33333'; include "/www/wwwroot/swoole/19/frame_swoole/frame/app/Http/view/index.html"; } }
HttpServer.php public function onRequest(SwooleRequest $request, SwooleResponse $response) { $uri = $request->server['request_uri']; if ($uri == '/favicon.ico') { $response->status(404); $response->end(''); return null; } // http://127.0.0.1:9000/index $httpRequest = HttpRequest::init($request); dd($httpRequest->getMethod(), "Method"); dd($httpRequest->getUriPath(), "UriPath"); // /index ob_start(); // 执行控制器的方法 app('route')->setMethod($httpRequest->getMethod())->match($httpRequest->getUriPath()); $result = ob_get_contents(); ob_end_clean(); $response->header('Content-Type', 'text/html'); $response->header('Charset', 'utf-8'); $response->end($result); }