@param $host
@param $port
@param $user
@param $password
@param $dbname

@return \databox
320052
public function mount($host, $port, $user, $password, $dbname)
    {
        $databox = $this->repository->mount($host, $port, $user, $password, $dbname);

        $this->clearCache();

        return $databox;
    }
695077
public function connect($host, $username, $password, $dbName, $charset = 'utf8', $engine = '', $pConnect = false)
    {
        $link = '';
        try {
            $host = explode(':', $host);
            if (substr($host[0], 0, 11) === 'unix_socket') {
                $dsn = "mysql:dbname={$dbName};unix_socket=" . substr($host[0], 12);
            } else {
                $dsn = "mysql:host={$host[0]};" . (isset($host[1]) ? "port={$host[1]};" : '') . "dbname={$dbName}";
            }

            if ($pConnect) {
                $link = new \PDO($dsn, $username, $password, [
                    \PDO::ATTR_PERSISTENT => true,
                    \PDO::ATTR_EMULATE_PREPARES => false,
                    \PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES $charset"
                ]);
            } else {
                $link = new \PDO($dsn, $username, $password, [
                    \PDO::ATTR_EMULATE_PREPARES => false,
                    \PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES $charset"
                ]);
            }
        } catch (\PDOException $e) {
            throw new PdoConnectException(
                'Pdo Connect Error! ｛' .
                $host[0] . (isset($host[1]) ? ':' . $host[1] : '') . ', ' . $dbName .
                '} Code:' . $e->getCode() . ', ErrorInfo!:' . $e->getMessage(),
                0,
                $e
            );
        }
        //$link->exec("SET names $charset");
        isset($this->conf['sql_mode']) && $link->exec('set sql_mode="' . $this->conf['sql_mode'] . '";'); //放数据库配 特殊情况才开
        if (!empty($engine) && $engine == 'InnoDB') {
            $link->exec('SET innodb_flush_log_at_trx_commit=2');
        }
        return $link;
    }
1223403
public function addRedisServer($host, $port = 6379, $db = 0, $timeout = 5, $auth = '') {
		$this->settings = [
			'host'    => $host,
			'port'    => $port,
			'db'      => $db,
			'timeout' => $timeout,
			'auth'    => $auth
		];
	}
162573
public function withSocks5(string $host, int $port, ?string $username, ?string $password): self
    {
        $this->proxy = [
            'socks5_host' => $host,
            'socks5_port' => $port,
            'socks5_username' => $username,
            'socks5_password' => $password,
        ];

        return $this;
    }
792895
public static function connect($db, $host = 'localhost', $port = 27017)
  {
    // TODO: Use MongoDB\Driver\Manager
    self::$cnxHandler = new \MongoClient($host.':'.$port);
    self::$db = self::$cnxHandler->$db;

    if (!self::$cnxHandler || !self::$db) {
      return false;
    } else {
      return true;
    }
  }
1302769
public static function buildAsync(
        $host,
        $port,
        $user,
        $pass,
        $exchangeName,
        $escapeMode = self::ESCAPE_MODE_SERIALIZE,
        $timeout = 0
    ) {
        return self::build($host, $port, $user, $pass, $exchangeName, false, $escapeMode, $timeout);
    }
1008132
public function devServer(string $host, int $port)
    {
        // Mark server mode
        define('SERVER_MODE', 'buildin');

        $this->config['host'] = $host;
        $this->config['port'] = $port;

        $this->printServerFinger();

        // Start cli Development Server
        $bind_http = $host . ':' . $port;
        passthru("php -S {$bind_http} -t " . APP_PATH . "/public");
    }
128632
public function setDatabase ($name, $user, $pass, $host = 'localhost', $port = 3306)
    {
        $this->database['name'] = $name;
        $this->database['user'] = $user;
        $this->database['pass'] = $pass;
        $this->database['host'] = $host;
        $this->database['port'] = $port;

        return $this;
    }
30795
public function connect($host = null, $port = null)
    {
        $this->_host = null !== $host ? $host : $this->_host;
        $this->_port = null !== $port ? $port : $this->_port;
        if (false === $this->_ssh_resource = ssh2_connect($this->_host, $this->_port)) {
            throw new TransportException(sprintf('Enable to connect to %s:%i.', $this->_host, $this->_port));
        }

        return $this;
    }
1164620
protected function setHost($host, $port = null)
    {
        $this->host = $host;
        if ($port !== null) {
            if (is_numeric($port)) {
                $this->port = (int) $port;
            } else {
                throw new ConfigurationException("Port '{$port}' is not numeric");
            }
        }
    }
742039
protected function config($host, $database, $user, $password)
    {
        //if(Config::get("database.host")=="" && Config::get("database.username")=="" && Config::get("database.password")=="" && Config::get("database.database")=="") throw new DatabaseArgumentsException();
        return [
            'host'     => $this->setLocal($host ? $host : Config::get('database.host')),
            'database' => $database ? $database : Config::get('database.database'),
            'user'     => $user ? $user : Config::get('database.username'),
            'password' => $password ? $password : Config::get('database.password'),
        ];
    }
1033734
public function create($host = '', $port = '')
    {
        $this->host = ($host != '') ? $host : 'localhost';
        $this->port = ($port != '') ? $port : 11211;

        if (is_null($this->memory)) {
            $this->memory = new \Memcache();
            $this->isEnabled = true;

            if (!$this->memory->connect($this->host, $this->port)) { // Instead 'localhost' here can be IP
                $this->memory = null;
                $this->isEnabled = true;
            }
        }

        return $this;
    }
1373593
public function connectUdp($host, $port)
    {
        $this->type = 'udp';
        $pton = @inet_pton($host);
        if ($pton === false) { // dirty check
            \PHPDaemon\Clients\DNS\Pool::getInstance()->resolve($host, function ($result) use ($host, $port) {
                if (!$result) {
                    Daemon::log(get_class($this) . '->connectUdp : unable to resolve hostname: ' . $host);
                    $this->onStateEv($this->bev, \EventBufferEvent::ERROR);
                    return;
                }
                // @todo stack of addrs
                if (is_array($result)) {
                    srand(Daemon::$process->getPid());
                    $real = $result[rand(0, sizeof($result) - 1)];
                    srand();
                } else {
                    $real = $result;
                }
                $this->connectUdp($real, $port);
            });
            return true;
        }
        $this->hostReal = $host;
        if ($this->host === null) {
            $this->host = $this->hostReal;
        }
        $l = mb_orig_strlen($pton);
        if ($l === 4) {
            $this->addr = $host . ':' . $port;
            /* @TODO: use EventUtil::SOCK_DGRAM */
            $fd = socket_create(\EventUtil::AF_INET, SOCK_DGRAM, \EventUtil::SOL_UDP);
        } elseif ($l === 16) {
            $this->addr = '[' . $host . ']:' . $port;
            $fd = socket_create(\EventUtil::AF_INET6, SOCK_DGRAM, \EventUtil::SOL_UDP);
        } else {
            return false;
        }
        if (!$fd) {
            return false;
        }
        socket_set_nonblock($fd);
        @socket_connect($fd, $host, $port);
        socket_getsockname($fd, $this->locAddr, $this->locPort);
        $this->setFd($fd);
        if (!$this->bev) {
            return false;
        }
        return true;
    }
1372128
public function newConnection($host, $database, $user, $password)
    {
        return self::$driver->connect($host, $database, $user, $password);
    }
655472
public function createDoctrineDBALConnection($driver, $host, $port, $dbname, $user, $password)
    {
        // TODO caching for connection

        $connectionFactory = $this->getDoctrineConnectionFactory();

        $connection = $connectionFactory->createConnection(array(
            'driver' => $driver,
            'host' => $host,
            'port' => $port,
            'dbname' => $dbname,
            'user' => $user,
            'password' => $password,
        ));

        return $connection;
    }
167127
private static function createSocket($host, $port, $sendTimeout, $receiveTimeout)
    {
        $socket = new TSocket($host, $port, true);
        if (null !== $sendTimeout) {
            $socket->setSendTimeout($sendTimeout);
        }

        if (null !== $receiveTimeout) {
            $socket->setRecvTimeout($receiveTimeout);
        }

        return $socket;
    }
926089
public function write($name, $username, $password, $host)
    {
        Dotenv::makeMutable();

        $environmentFile = $this->finder->get($this->template);

        $replace = [
            "DB_HOST=$host",
            "DB_DATABASE=$name",
            "DB_USERNAME=$username",
            "DB_PASSWORD=$password",
        ];

        $newEnvironmentFile = str_replace($this->search, $replace, $environmentFile);

        $this->finder->put($this->file, $newEnvironmentFile);

        Dotenv::makeImmutable();
    }