private function launchServices(array $services) { foreach ($services as $service) { $this->loaded[] = $service; $this->application->registerDeferredProvider($service); } return $this; }
/** * Registers the server in the container. * * @return \Illuminate\Foundation\Application * @throws \Exception */ public function register() { // Auto register the support service provider if (!get_class($this) == SupportServiceProvider::class) { $this->app->register(SupportServiceProvider::class); } $this->viewsPath = Str::replace($this->viewsPath, '{resourcesPath}', $this->getResourcesPath()); $this->assetsPath = Str::replace($this->assetsPath, '{resourcesPath}', $this->getResourcesPath()); $router = $this->app->make('router'); $kernel = $this->app->make('Illuminate\\Contracts\\Http\\Kernel'); $this->registerConfigFiles(); foreach ($this->prependMiddleware as $middleware) { $kernel->prependMiddleware($middleware); } foreach ($this->middleware as $middleware) { $kernel->pushMiddleware($middleware); } foreach ($this->routeMiddleware as $key => $middleware) { $router->middleware($key, $middleware); } foreach ($this->providers as $provider) { $this->app->register($provider); } foreach ($this->deferredProviders as $provider) { $this->app->registerDeferredProvider($provider); } foreach ($this->bindings as $binding => $class) { $this->app->bind($binding, $class); } foreach ($this->singletons as $binding => $class) { if ($this->strict && !class_exists($class) && !interface_exists($class)) { throw new \Exception(get_called_class() . ": Could not find alias class [{$class}]. This exception is only thrown when \$strict checking is enabled"); } $this->app->singleton($binding, $class); } foreach ($this->aliases as $alias => $full) { if ($this->strict && !class_exists($full) && !interface_exists($full)) { throw new \Exception(get_called_class() . ": Could not find alias class [{$full}]. This exception is only thrown when \$strict checking is enabled"); } $this->app->alias($alias, $full); } if (is_array($this->commands) and count($this->commands) > 0) { $this->commands($this->commands); } AliasLoader::getInstance($this->facades)->register(); $this->requireHelpersFor('register'); return $this->app; }