路由
- Application __construct 注册路由到服务容器
- setBasePath
- registerBaseBindings
- registerBaseServiceProviders
- EventServiceProvider
- LogServiceProvider
- RoutingServiceProvider
- registerRouter
- registerCoreContainerAliases
- 加载路由文件
- App\Providers\RouteServiceProvider
- boot
- Illuminate\Foundation\Support\Providers
- boot
- routesAreCached 获取缓存
- $this[‘files’]查找是否存在文件
- getCachedRoutesPath
- $this->bootstrapPath().‘/cache/routes.php’;
- $this[‘files’]查找是否存在文件
- 存在则加载缓存文件 loadCachedRoutes
- 不存在则加载路由,并且调用loadRoutes函数,loadRoutes会调用App\Providers\RouteServiceProvider的map方法来将路由名和路由行为循环刷新方法加入到启动回到中待启动后执行。
- Illuminate\Foundation\Support\Providers
- map
- mapApiRoutes,mapWebRoutes,调用web,api两个路由:router/web.php,router/api.php
- boot
- 路由注册
- 各种方法,都是调用:addRoute
- createRoute 创建路由
- 对controller@action转换为’name’=>controller@action convertToControllerAction
- 创建新路由
- 设置路由
- 设置容器
- 是否有分组前缀,有则执行合并分组属性到路由
- 加上条件闭包回调到路由
- 返回路由
- 添加路由到 RouteCollection
- add
- addToCollections
- 循环添加到 t h i s − > r o u t e s [ this->routes[ this−>routes[method][$domainAndUri] 二维数组路由 ‘GET’ => [ $routeUri1 => $routerA ]
- 添加到 t h i s − > a l l R o u t e s [ this->allRoutes[ this−>allRoutes[method.$domainAndUri] 二维数组转为一维数组的路由 ‘GET’ . $routeUri1 => $routerA
- addLookups
- 添加别名到命名空间$nameList中方便查找 $routeName1 => $routeA
- 设置了控制器,则添加到行为列表$actionList查找 ‘Controller@action’ => $routeA
- 返回路由
- 路由寻址 RouteCollection
- sendRequestThroughRouter
- dispatchToRouter
- Router/dispatch
- dispatchToRoute
- findRoute
- match
- 匹配路由 找到第一个
- compileRoute 解析路由: 将路由规则转换成正则表达式
- 循环执行每个验证器
- 匹配路由 找到第一个
- dispatchToRoute
- Router/dispatch
- dispatchToRouter
- sendRequestThroughRouter
- App\Providers\RouteServiceProvider