/** * Register a provider. * * @param string $root root * @param Provider $provider provider * @param closure|null configuration closure */ public function registerProvider($root, Provider $provider, $config = null) { $provider->setContainer($this); $provider->setRoot($root); if ($config) { $config($provider); } $provider->provide($this); $this->providers[$root] = $provider; return $this; }