<?php

require 'autoloader.php';
use js\tools\dbhandler\exceptions\DbException;
use js\tools\dbhandler\Handler;
use js\tools\dbhandler\parameters\MySQL;
try {
    // TODO set your own test connection parameters!
    $handler = Handler::getConnection('test', MySQL::viaHost('test', 'test', 'test'));
    // this is the mysql.ini variable that should be adjusted according to needs
    // but it works via query as well
    $handler->exec('SET SESSION wait_timeout = 1');
    echo 'connection timeout set to 1 second, sleeping', PHP_EOL;
    sleep(3);
    if ($handler->checkConnection()) {
        echo 'connection is good', PHP_EOL;
    } else {
        echo 'connection is down, reconnecting', PHP_EOL;
        $handler->connect();
    }
    if ($handler->checkConnection()) {
        echo 'connection is now good', PHP_EOL;
    } else {
        echo 'connection is still down, failed to reconnect', PHP_EOL;
    }
} catch (DbException $e) {
    echo $e->getMessage(), PHP_EOL;
    die;
}
<?php

use js\tools\dbhandler\parameters\ConnectionParameters;
use js\tools\dbhandler\parameters\MySQL;
use js\tools\dbhandler\parameters\OCI;
use js\tools\dbhandler\parameters\ODBC;
use js\tools\dbhandler\parameters\PostgreSQL;
use js\tools\dbhandler\parameters\SQLite;
use js\tools\dbhandler\parameters\SQLServerOfficial;
use js\tools\dbhandler\parameters\SQLServerSybase;
use js\tools\dbhandler\parameters\SQLServerTDS;
use js\tools\dbhandler\parameters\SQLSrv;
require 'autoloader.php';
$host = 'localhost';
$port = 1234;
$dbname = 'test';
$username = '******';
$password = '******';
/** @var ConnectionParameters[] $parameters */
$parameters = [MySQL::viaHost($dbname, $username, $password, $host, $port), PostgreSQL::viaHost($dbname, $username, $password, $host, $port), SQLSrv::viaHost($dbname, $username, $password, $host, $port), SQLSrv::viaHost($dbname, $username, $password, 'foo.database.windows.net', $port), SQLServerOfficial::viaHost($dbname, $username, $password, $host, $port), SQLServerSybase::viaHost($dbname, $username, $password, $host, $port), SQLServerTDS::viaHost($dbname, $username, $password, $host, $port), ODBC::viaCataloged($dbname, $username, $password), ODBC::viaHost($dbname, $username, $password, $host), OCI::viaHost($dbname, $username, $password, $host, $port), SQLite::create(':memory:', $username, $password)];
foreach ($parameters as $container) {
    echo get_class($container), ' - ', $container->getConnectionString(), PHP_EOL;
}