aliensdev/ad-router

此包的最新版本(dev-master)没有可用的许可信息。

dev-master 2020-09-22 15:08 UTC

This package is not auto-updated.

Last update: 2024-09-29 06:25:41 UTC


README

如何工作

  1. 捕获请求
    - $request = ServerRequest::fromGlobals();
    
  2. 实例化路由器
    - $router = new Router();
    
  3. 添加路由
    - $router->addRoute("GET","/",[HomeController::class, "index"]);
    
  4. 获取相应路由
    - $route = $router->match($request);
    
  5. 生成响应
     if(! is_null($route)) {
        // if route Found !
         $response = $router->dispatch($route);
     }else {
        // if route isn't found
         $response = new Response(404,[],"Not Found!");
     }
    
  6. 发送响应
    - send($response);