EventServieProvider —— 事件服务提供者
$this->app->singleton('events', function ($app) {
return (new Dispatcher($app))->setQueueResolver(function () use ($app) {
return $app->make('Illuminate\Contracts\Queue\Factory');
});
});
RoutingServiceProvider —— 路由服务提供者
public function register()
{
$this->registerRouter();
$this->registerUrlGenerator();
$this->registerRedirector();
$this->registerPsrRequest();
$this->registerPsrResponse();
$this->registerResponseFactory();
}
更多详情查看源码:Illuminate\Routing\RoutingServiceProvider.php
更多详情查看源码:Illuminate\Foundation\Application.php第1026行registerCoreContainerAliases方法。
if ($basePath) {
$this->setBasePath($basePath);
}
更多详情查看源码:Illuminate\Foundation\Application.php第262行setBasePath方法。
解析Illuminate\Contracts\Http\Kernel,实例化App\Http\Kernel
a.构造函数:设置$app/$router,初始化$router中middleware数值
b.handle处理请求 —— 经过路由发送请求:
bootstrap方法,启动一系列启动类的bootstrap方法:
Pipeline发送请求,经过中间件,再由路由转发,最终返回响应
new Pipeline($this->app))
->send($request)
->through($this->middleware)
->then($this->dispatchToRouter()
c.将响应信息发送到浏览器:
$response->send();
d.处理继承自TerminableMiddleware接口的中间件(Session)并结束应用生命周期:
$kernel->terminate($request, $response);