protected function registerBaseServiceProviders()
{
$this->register(new EventServiceProvider($this));
$this->register(new LogServiceProvider($this));
$this->register(new RoutingServiceProvider($this));
}
public function register($provider, $force = false)
{
....
$provider->register();
....
return $provider;
}
//此处$this指向RoutingServiceProvider
public function register()
{
$this->registerRouter();
$this->registerUrlGenerator();
$this->registerRedirector();
$this->registerPsrRequest();
$this->registerPsrResponse();
$this->registerResponseFactory();
$this->registerCallableDispatcher();
$this->registerControllerDispatcher();
}
protected function registerRouter()
{
$this->app->singleton('router', function ($app){
return new Router($app['events'], $app);
});
}