public function start() { $host = Config::get('mongo.host', '127.0.0.1'); $port = Config::get('mongo.port', 27017); $protocol = Config::get('mongo.protocol', 'mongodb'); $auth = Config::get('mongo.auth', true); if ($auth) { $user = Config::get('mongo.username', SITE_NAME . '_master'); $password = Config::get('mongo.password'); $dsn = $protocol . '://' . $user . ':' . $password . '@' . $host . ':' . $port; } else { $dsn = $protocol . '://' . $host . ':' . $port; } return Mdb::connection($dsn, ['connect' => true]); }