重新思考框架架构

Fork Me On Github
zodream zodream框架 2018年12月

当前版本

php
                            

$app = new Web();
    $app->register();
$app->autoResponse();
    $response = $app->handle($uri);
        $app->isAllowDomain();  // 这里会判断是否允许域名访问
        $uri = $app->fomat($uri);
            $app['url']->deRewrite($uri);
        $route = $app[Router]->handle($uri)
            new Router()
                $router->get('');
            reurn new Route();
        $route->handle($app['request'], $app['response'])
            $module = $router->getMoudle()
            $module->boot();
            $module->invoke()
                return
            $package = $module->getControlerNamespace();
            $controller = $route->getController($package)
            $controller->init();
            $controller->invoke($action);
                $controller->beforeFilter()
                $controller->$action()
                    $app['view']->render()
    $response->send();
        $response->sendHeader();
        $response->sendContent();
12345678910111213141516171819202122232425262728

中间件版本

php
                          

$app = new Web()
$app->middleware(Middleware::class)
$app->middleware(function($req, $resp, $next))
$response = $app->handle($uri)
    DomainMiddleware       // 是否允许当前域名
        CORSMiddleware     // 跨域验证
            CacheMiddleware    // 静态缓存检测
                GZIPMiddleware   // 压缩输出
                    RewriteMiddleware   // 重写解析还原真实
                        RouterMiddleware   // 路由解析,下一步到控制器
                            MatchRouteMiddle
                                [any]Middleware
                            ModuleMiddleware
                            DefaultRouteMiddle
                                Controller
                                    CSRFMiddleware
                                        RuleMiddleware  // 控制器中的规则过滤
                                            AuthMiddleware        // 登陆验证
                                            HttpMethodMiddleware  // 请求方式验证
                                            RoleMiddleware      // 角色验证
                                                UriParameterMiddleware // 方法参数过滤
                                                    ResponseBodyMiddleware   // 加密解密

$response->send();
1234567891011121314151617181920212223242526

目前还不确定是否升级

点击查看全文
0 412 0