PHP code example of phattarachai / laravel-db-tunnel
1. Go to this page and download the library: Download phattarachai/laravel-db-tunnel 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/ */
'tunnels' => [
'claude-prod' => [
'alias' => 'prod', // the ~/.ssh/config Host you already log in with
'remote_port' => 5432, // the database port on that box
],
],
return [
'tunnels' => [
'claude-qas' => [
'alias' => 'qas', // where the DB listens, as seen from the box
'port_env' => 'QAS_DB_PORT', // default: DB_PORT for the default connection, else <NAME>_DB_PORT
// with a `claude-` prefix dropped
'auto_open' => true,
'host' => '203.0.113.5', // only used to print a Host block when the alias is missing
'user' => 'deploy',
],
],
'auto_open' => env('DB_TUNNEL_AUTO_OPEN'), // null → local only
'port_range' => [15440, 15999],
'registry' => env('DB_TUNNEL_REGISTRY'), // null → ~/.config/db-tunnel/ports.json
'ssh_config' => env('DB_TUNNEL_SSH_CONFIG'), // null → ~/.ssh/config
'probe' => env('DB_TUNNEL_PROBE', 'auto'), // auto | lsof | ss
'connect_timeout' => 30, // seconds before a detached dial is abandoned
'wait' => 10, // seconds `open` waits for the port to listen
'keepalive' => ['interval' => 15, 'count_max' => 8],
'watch' => ['establish_timeout' => 90, 'redial_delay' => 3],
];
sql
CREATE ROLE "claude-prod" LOGIN PASSWORD '<generated>';
GRANT CONNECT ON DATABASE app TO "claude-prod";
GRANT USAGE ON SCHEMA public TO "claude-prod";
GRANT SELECT ON ALL TABLES IN SCHEMA public TO "claude-prod";
GRANT SELECT ON ALL SEQUENCES IN SCHEMA public TO "claude-prod";
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO "claude-prod";
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON SEQUENCES TO "claude-prod";
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.