mkubenka/yii2-db-reconnect

Yii2 DB Auto Reconnect

Installs: 14 914

Dependents: 1

Suggesters: 0

Security: 0

Stars: 6

Watchers: 3

Forks: 1

Open Issues: 0

Type:yii2-extension

1.1.1 2019-09-15 10:48 UTC

This package is not auto-updated.

Last update: 2024-04-28 00:43:03 UTC


README

Latest Stable Version

Inspired by:

https://github.com/xjflyttp/yii2-db-reconnect

Installation

composer require mkubenka/yii2-db-reconnect

or

"require": {
    "mkubenka/yii2-db-reconnect": "~1.0"
},

Configuration

'db' => [
    'class' => 'mkubenka\dbreconnect\mysql\Connection',
    'reconnectMaxCount' => 2,
    'dsn' => 'mysql:host=127.0.0.1;dbname=test',
    'username' => 'root',
    'password' => '',
    'charset' => 'utf8',
],

Logging

'log' => [
    'targets' => [
        [
            'class' => 'yii\log\FileTarget',
            'levels' => ['error', 'info'],
            'maxLogFiles' => 20,
            'maxFileSize' => 2048,
            'categories' => [
                'mkubenka\dbreconnect\*',
            ],
            'logFile' => '@frontend/runtime/logs/dbreconnect.log',
        ],
    ],
],

Known limitations

This method only works for non transactional statements.