/** * Register the application service providers. * * @param array $providers * @return void */ public function load(array $providers) { $manifest = $this->loadManifest(); // First we will load the service manifest, which contains information on all // service providers registered with the application and which services it // provides. This is used to know which services are "deferred" loaders. if ($this->shouldRecompile($manifest, $providers)) { $manifest = $this->compileManifest($providers); } // If the application is running in the console, we will not lazy load any of // the service providers. This is mainly because it's not as necessary for // performance and also so any provided Artisan commands get registered. if ($this->app->runningInConsole()) { $manifest['eager'] = $manifest['providers']; } // Next, we will register events to load the providers for each of the events // that it has requested. This allows the service provider to defer itself // while still getting automatically loaded when a certain event occurs. foreach ($manifest['when'] as $provider => $events) { $this->registerLoadEvents($provider, $events); } // We will go ahead and register all of the eagerly loaded providers with the // application so their services can be registered with the application as // a provided service. Then we will set the deferred service list on it. foreach ($manifest['eager'] as $provider) { $this->app->register($this->createProvider($provider)); } $this->app->setDeferredServices($manifest['deferred']); }
/** * @param array $providers * * @return void */ public function load(array $providers) { $manifest = $this->loadManifest(); if ($this->shouldRecompile($manifest, $providers)) { $manifest = $this->compileManifest($providers); } foreach ($manifest['when'] as $provider => $events) { $this->registerLoadEvents($provider, $events); } foreach ($manifest['eager'] as $provider) { $this->app->register($this->createProvider($provider)); } $this->app->addDeferredServices($manifest['deferred']); }
/** * Load service providers for active modules */ public function loadServiceProviders() { $this->withServiceProviders()->each(function ($module) { /* @var Module $module */ $this->app->register($module->serviceProviderClass()); }); }
protected function install() { try { $this->storeConfiguration(); $this->runMigrations(); $this->writeSettings(); $this->application->register('Flarum\\Core\\CoreServiceProvider'); $resolver = $this->application->make('Illuminate\\Database\\ConnectionResolverInterface'); Model::setConnectionResolver($resolver); Model::setEventDispatcher($this->application->make('events')); $this->seedGroups(); $this->seedPermissions(); $this->createAdminUser(); $this->enableBundledExtensions(); } catch (Exception $e) { @unlink($this->getConfigFile()); throw $e; } }
/** * Load the providers. * * @return \Jenky\LaravelEnvLoader\Loader */ public function loadProviders() { $this->loadData(config('env.providers'), function ($configs) { if (!empty($configs) && is_array($configs)) { foreach ($configs as $config) { $this->app->register($config); } } }); return $this; }
/** * Register the application service providers. * * @param array $providers * @return void */ public function load(array $providers) { $manifest = $this->loadManifest(); // First we will load the service manifest, which contains information on all // service providers registered with the application and which services it // provides. This is used to know which services are "deferred" loaders. if ($this->shouldRecompile($manifest, $providers)) { $manifest = $this->compileManifest($providers); } // Next, we will register events to load the providers for each of the events // that it has requested. This allows the service provider to defer itself // while still getting automatically loaded when a certain event occurs. foreach ($manifest['when'] as $provider => $events) { $this->registerLoadEvents($provider, $events); } // We will go ahead and register all of the eagerly loaded providers with the // application so their services can be registered with the application as // a provided service. Then we will set the deferred service list on it. foreach ($manifest['eager'] as $provider) { $this->app->register($this->createProvider($provider)); } $this->app->addDeferredServices($manifest['deferred']); }
/** * 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; }
protected function install() { try { $this->dbConfig = $this->dataSource->getDatabaseConfiguration(); $validation = $this->getValidator()->make($this->dbConfig, ['driver' => 'required|in:mysql', 'host' => 'required', 'database' => 'required|string', 'username' => 'required|string', 'prefix' => 'alpha_dash|max:10']); if ($validation->fails()) { throw new Exception(implode("\n", call_user_func_array('array_merge', $validation->getMessageBag()->toArray()))); } $this->baseUrl = $this->dataSource->getBaseUrl(); $this->settings = $this->dataSource->getSettings(); $this->adminUser = $admin = $this->dataSource->getAdminUser(); if (strlen($admin['password']) < 8) { throw new Exception('Password must be at least 8 characters.'); } if ($admin['password'] !== $admin['password_confirmation']) { throw new Exception('The password did not match its confirmation.'); } if (!filter_var($admin['email'], FILTER_VALIDATE_EMAIL)) { throw new Exception('You must enter a valid email.'); } if (!$admin['username'] || preg_match('/[^a-z0-9_-]/i', $admin['username'])) { throw new Exception('Username can only contain letters, numbers, underscores, and dashes.'); } $this->storeConfiguration(); $resolver = $this->application->make('Illuminate\\Database\\ConnectionResolverInterface'); AbstractModel::setConnectionResolver($resolver); AbstractModel::setEventDispatcher($this->application->make('events')); $this->runMigrations(); $this->writeSettings(); $this->application->register('Flarum\\Core\\CoreServiceProvider'); $this->seedGroups(); $this->seedPermissions(); $this->createAdminUser(); $this->enableBundledExtensions(); $this->publishAssets(); } catch (Exception $e) { @unlink($this->getConfigFile()); throw $e; } }
/** * register addon version 5. * * @param \Illuminate\Contracts\Foundation\Application $app */ protected function registerV5(Application $app) { // regist service providers $providers = $this->config('addon.providers', []); foreach ($providers as $provider) { $app->register($provider); } }
/** * Boot module Service Provider * * @param \CID\Core\Module\Json $module */ protected function bootServiceProvider(Json $module) { foreach ($module->getModuleServiceProviders() as $provider) { $this->app->register($provider); } }
/** * Register the addon providers. * * @param AddonServiceProvider $provider */ protected function registerProviders(AddonServiceProvider $provider) { foreach ($provider->getProviders() as $provider) { $this->application->register($provider); } }
/** * @param Application $app */ protected function bootstrapBluemix($app) { // Get an instance of the cluster service $app->register(new BluemixServiceProvider($app)); $_service = BluemixServiceProvider::service($app); $_vars = ['DB_DRIVER' => 'mysql']; // Get the cluster database information foreach ($_service->getDatabaseConfig() as $_key => $_value) { $_vars['DB_' . strtr(strtoupper($_key), '-', '_')] = $_value; } // Now jam everything into the environment foreach ($_vars as $_key => $_value) { putenv($_key . '=' . $_value); $_ENV[$_key] = $_value; $_SERVER[$_key] = $_value; } // Finally, let the cluster service push some middleware onto the stack if ($_service instanceof HasMiddleware) { $_service->pushMiddleware($app->make('Illuminate\\Contracts\\Http\\Kernel')); } }