laravel启动流程
2017-02-21 16:54:12 0 举报
AI智能生成
laravel启动流程
作者其他创作
大纲/内容
bootstrap/autoload.php
bootstrap/app.php
实例化应用程序app
注册基本绑定
注册基本服务提供者
事件服务提供者($this->register(new EventServiceProvider($this));)
路由服务提供者($this->register(new RoutingServiceProvider($this));)
实际运行的是服务器提供者的register方法($provider->register();)
$this->registerRouter();
$this->registerUrlGenerator();
$this->registerRedirector();
$this->registerPsrRequest();
$this->registerPsrResponse();
$this->registerResponseFactory();
注册核心的容器别名
设置根路径($this->setBasePath($basePath);)
向容器中注册App\Http\Kernel
向容器中注册App\Console\Kernel
向容器中注册App\Exception\Kernel
实例化Http\Kernel($kernel = $app->make)
设置实例的$app和$router属性
初始化路由器的中间件顺序
将Http\Kernel类中定义的中间件和中间建组赋予给$router
处理请求($response = $kernel->handle)
将请求交由路由器处理($response = $this->sendRequestThroughRouter($request))
向容器中注册request实例
清空之前的request实例
调用bootstrap方法,启动一系列启动类的bootstrap方法
Illuminate\Foundation\Bootstrap\DetectEnvironment 环境配置($app[‘env’])
Illuminate\Foundation\Bootstrap\LoadConfiguration 基本配置($app[‘config’])
Illuminate\Foundation\Bootstrap\ConfigureLogging 日志文件($app[‘log’])
Illuminate\Foundation\Bootstrap\HandleExceptions 错误&异常处理
Illuminate\Foundation\Bootstrap\RegisterFacades 清除已解析的Facade并重新启动,注册config文件中alias定义的所有Facade类到容器
Illuminate\Foundation\Bootstrap\RegisterProviders 注册config/app.php中providers定义的所有Providers类到容器
$app->registerConfiguredProviders();
Illuminate\Foundation\Bootstrap\BootProviders 调用app的boot方法
调用provider的boot方法($this->bootProvider($p);)
return $this->call([$provider, 'boot']);
通过Pipeline发送请求,经过中间件,再由路由转发,最终返回响应
发送响应到浏览器($response->send();)
终结app($kernel->terminate($request, $response);)

收藏
0 条评论
下一页