Skip to content

Instantly share code, notes, and snippets.

@DarkGhostHunter
Created September 19, 2018 15:54
Show Gist options
  • Save DarkGhostHunter/25e3b2d95ae54e181223915b4b7e59d4 to your computer and use it in GitHub Desktop.
Save DarkGhostHunter/25e3b2d95ae54e181223915b4b7e59d4 to your computer and use it in GitHub Desktop.
Illuminate\Database\DatabaseServiceProvider@registerConnectionServices
<?php
/**
* Register the primary database bindings.
*
* @return void
*/
protected function registerConnectionServices()
{
// The connection factory is used to create the actual connection instances on
// the database. We will inject the factory into the manager so that it may
// make the connections while they are actually needed and not of before.
$this->app->singleton('db.factory', function ($app) {
return new ConnectionFactory($app);
});
// The database manager is used to resolve various connections, since multiple
// connections might be managed. It also implements the connection resolver
// interface which may be used by other components requiring connections.
$this->app->singleton('db', function ($app) {
return new DatabaseManager($app, $app['db.factory']);
});
$this->app->bind('db.connection', function ($app) {
return $app['db']->connection();
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment