PHPackages                             hongxunpan/db - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. hongxunpan/db

ActiveLibrary

hongxunpan/db
=============

connections for db, such as mysql &amp; redis ...

1.0.2(3y ago)01801MITPHPPHP &gt;=5.6

Since Oct 12Pushed 3y ago1 watchersCompare

[ Source](https://github.com/HongXunPan/db-connection)[ Packagist](https://packagist.org/packages/hongxunpan/db)[ RSS](/packages/hongxunpan-db/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (1)Versions (4)Used By (1)

db-connection DB 连接器封装包
=======================

[](#db-connection-db-连接器封装包)

including :

- redis
- mysqli
- pdo

install
-------

[](#install)

`composer require hongxunpan/db`

usage
-----

[](#usage)

### redis (\\HongXunPan\\DB\\Redis\\Redis)

[](#redis-hongxunpandbredisredis)

#### set config

[](#set-config)

```
$config = ['host' => '192.168.0.1'];
\HongXunPan\DB\Redis\Redis::setConfig($config, 'default');//array $config = [], $connectName = 'default', array $options = []
```

default setting

```
$default = [
    'host' => '127.0.0.1',
    'port' => 6379,
    'timeout' => 0.0,
    'reserved' => null,
    'retryInterval' => 0,
    'readTimeout' => 0.0
];
```

#### using

[](#using)

```
$res = \HongXunPan\DB\Redis\Redis::connection()->set('test', 'test');
$res = \HongXunPan\DB\Redis\Redis::connection('xxx')->getConnection()->set('test', 'test1');
$res = \HongXunPan\DB\Redis\Redis::connection('aaa')->incr('testIncr');
/** \Redis $res */
var_dump($res);
```

### mysqli

[](#mysqli)

#### set config

[](#set-config-1)

```
$config = [
    'host' => '192.168.65.2',
    'port' => 3306,
    'username' => 'default',
    'password' => 'secret',
    'database' => '',
];

\HongXunPan\DB\Mysql\Mysqli\Mysqli::setConfig($config, 'default');
```

#### using

[](#using-1)

```
/** @var PDO $res */
$res = \HongXunPan\DB\Mysql\Mysqli\Mysqli::connection('default')->getConnection();
$res = \HongXunPan\DB\Mysql\Mysqli\Mysqli::getConnection();
var_dump($res);
```

### pdo

[](#pdo)

#### set config

[](#set-config-2)

```
$config = [
    'host' => '192.168.65.2',
    'port' => 3306,
    'username' => 'default',
    'password' => 'secret',
];

\HongXunPan\DB\Mysql\Pdo\Pdo::setConfig($config, 'default');
```

#### using

[](#using-2)

```
$res = \HongXunPan\DB\Mysql\Pdo\Pdo::connection('default')->getConnection();
$res = \HongXunPan\DB\Mysql\Pdo\Pdo::getConnection('default')
```

update log
----------

[](#update-log)

- `1.0.2` 2022-10-15 fix connection() doc tips
- `1.0.1` 2022-10-13 fix singleton extends bug
- `1.0.0` 2022-10-13 version1, include redis &amp; mysqli &amp; pdo

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Total

3

Last Release

1308d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/37c4ffcd9218f6b9722875da1ec37f20b0118651687de5798972f919bd2c1eb4?d=identicon)[HongXunPan](/maintainers/HongXunPan)

---

Top Contributors

[![HongXunPan](https://avatars.githubusercontent.com/u/25816508?v=4)](https://github.com/HongXunPan "HongXunPan (13 commits)")

### Embed Badge

![Health badge](/badges/hongxunpan-db/health.svg)

```
[![Health](https://phpackages.com/badges/hongxunpan-db/health.svg)](https://phpackages.com/packages/hongxunpan-db)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
