PHP code example of bannerstop / tunneled-mysql

1. Go to this page and download the library: Download bannerstop/tunneled-mysql library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

bannerstop / tunneled-mysql example snippets


$tunnelBuilder = new \Bannerstop\TunneledMysql\TunnelBuilder(
    new \Bannerstop\TunneledMysql\SSH\SSHCredentials(
        'ssh.example.host',
        'user',
        'path/to/private_key'
    ),
    new \Bannerstop\TunneledMysql\MySQL\MySQLCredentials(
        'username',
        'pass',
        'dbname'
    ),
    (new \Bannerstop\TunneledMysql\Lib\GetAvailablePort())->execute()
);
$mysql = $tunnelBuilder->build()->run();

$query = $mysql->query('SELECT * FROM example LIMIT 1');
print_r($query->fetch());